< prev index next >

test/runtime/NMT/CommitOverlappingRegions.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary Test commits of overlapping regions of memory.
  27  * @key nmt jcmd
  28  * @library /testlibrary /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  * @build   CommitOverlappingRegions
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  34  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail CommitOverlappingRegions
  35  */
  36 
  37 import jdk.test.lib.*;


  38 import sun.hotspot.WhiteBox;
  39 
  40 public class CommitOverlappingRegions {
  41     public static WhiteBox wb = WhiteBox.getWhiteBox();
  42     public static void main(String args[]) throws Exception {
  43         OutputAnalyzer output;
  44 
  45         long size = 32 * 1024;
  46         int pagesize = wb.getVMPageSize();
  47         if (size < pagesize) { size = pagesize; }  // Should be aligned.
  48         long sizek = size / 1024;
  49 
  50         long addr = wb.NMTReserveMemory(8*size);
  51 
  52         String pid = Long.toString(ProcessTools.getProcessId());
  53         ProcessBuilder pb = new ProcessBuilder();
  54 
  55         pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
  56         System.out.println("Address is " + Long.toHexString(addr));
  57 




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary Test commits of overlapping regions of memory.
  27  * @key nmt jcmd
  28  * @library /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  * @build sun.hotspot.WhiteBox
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  34  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail CommitOverlappingRegions
  35  */
  36 
  37 import jdk.test.lib.process.ProcessTools;
  38 import jdk.test.lib.process.OutputAnalyzer;
  39 import jdk.test.lib.JDKToolFinder;
  40 import sun.hotspot.WhiteBox;
  41 
  42 public class CommitOverlappingRegions {
  43     public static WhiteBox wb = WhiteBox.getWhiteBox();
  44     public static void main(String args[]) throws Exception {
  45         OutputAnalyzer output;
  46 
  47         long size = 32 * 1024;
  48         int pagesize = wb.getVMPageSize();
  49         if (size < pagesize) { size = pagesize; }  // Should be aligned.
  50         long sizek = size / 1024;
  51 
  52         long addr = wb.NMTReserveMemory(8*size);
  53 
  54         String pid = Long.toString(ProcessTools.getProcessId());
  55         ProcessBuilder pb = new ProcessBuilder();
  56 
  57         pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
  58         System.out.println("Address is " + Long.toHexString(addr));
  59 


< prev index next >