< prev index next >

test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java

Print this page




  66 
  67         // All heap dumps should create 1.0.2 file format
  68         // Hotspot internal heapdumper always use HPROF_HEADER_1_0_2 format,
  69         // but SA heapdumper still use HPROF_HEADER_1_0_1 for small heaps
  70         testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);
  71 
  72         /**
  73          * This test was deliberately commented out since the test system lacks
  74          * support to handle the requirements for this kind of heap size in a
  75          * good way. If or when it becomes possible to run this kind of tests in
  76          * the test environment the test should be enabled again.
  77          * */
  78         // Large heap 2,2 gigabytes, should create 1.0.2 file format
  79         // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
  80     }
  81 
  82     private static void testHProfFileFormat(String vmArgs, long heapSize,
  83             String expectedFormat) throws Exception, IOException,
  84             InterruptedException, FileNotFoundException {
  85         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(
  86                 "--add-exports=java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize));


  87         procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
  88         Process largeHeapProc = procBuilder.start();
  89 
  90         try (Scanner largeHeapScanner = new Scanner(
  91                 largeHeapProc.getInputStream());) {
  92             String pidstring = null;



  93             while ((pidstring = largeHeapScanner.findInLine("PID\\[[0-9].*\\]")) == null) {
  94                 Thread.sleep(500);
  95             }
  96             int pid = Integer.parseInt(pidstring.substring(4,
  97                     pidstring.length() - 1));
  98             System.out.println("Extracted pid: " + pid);
  99 
 100             JDKToolLauncher jMapLauncher = JDKToolLauncher
 101                     .createUsingTestJDK("jhsdb");
 102             jMapLauncher.addToolArg("jmap");
 103             jMapLauncher.addToolArg("--binaryheap");
 104             jMapLauncher.addToolArg("--pid");
 105             jMapLauncher.addToolArg(String.valueOf(pid));
 106 
 107             ProcessBuilder jMapProcessBuilder = new ProcessBuilder(
 108                     jMapLauncher.getCommand());
 109             System.out.println("jmap command: "
 110                     + Arrays.toString(jMapLauncher.getCommand()));
 111 
 112             Process jMapProcess = jMapProcessBuilder.start();




  66 
  67         // All heap dumps should create 1.0.2 file format
  68         // Hotspot internal heapdumper always use HPROF_HEADER_1_0_2 format,
  69         // but SA heapdumper still use HPROF_HEADER_1_0_1 for small heaps
  70         testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);
  71 
  72         /**
  73          * This test was deliberately commented out since the test system lacks
  74          * support to handle the requirements for this kind of heap size in a
  75          * good way. If or when it becomes possible to run this kind of tests in
  76          * the test environment the test should be enabled again.
  77          * */
  78         // Large heap 2,2 gigabytes, should create 1.0.2 file format
  79         // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
  80     }
  81 
  82     private static void testHProfFileFormat(String vmArgs, long heapSize,
  83             String expectedFormat) throws Exception, IOException,
  84             InterruptedException, FileNotFoundException {
  85         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(
  86                 "--add-exports=java.management/sun.management=ALL-UNNAMED",
  87                 "--add-opens=java.management/sun.management=ALL-UNNAMED",
  88                 vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize));
  89         procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
  90         Process largeHeapProc = procBuilder.start();
  91 
  92         try (Scanner largeHeapScanner = new Scanner(
  93                 largeHeapProc.getInputStream());) {
  94             String pidstring = null;
  95             if (!largeHeapScanner.hasNext()) {
  96                throw new RuntimeException ("Test failed: could not open largeHeapScanner.");
  97             }
  98             while ((pidstring = largeHeapScanner.findInLine("PID\\[[0-9].*\\]")) == null) {
  99                 Thread.sleep(500);
 100             }
 101             int pid = Integer.parseInt(pidstring.substring(4,
 102                     pidstring.length() - 1));
 103             System.out.println("Extracted pid: " + pid);
 104 
 105             JDKToolLauncher jMapLauncher = JDKToolLauncher
 106                     .createUsingTestJDK("jhsdb");
 107             jMapLauncher.addToolArg("jmap");
 108             jMapLauncher.addToolArg("--binaryheap");
 109             jMapLauncher.addToolArg("--pid");
 110             jMapLauncher.addToolArg(String.valueOf(pid));
 111 
 112             ProcessBuilder jMapProcessBuilder = new ProcessBuilder(
 113                     jMapLauncher.getCommand());
 114             System.out.println("jmap command: "
 115                     + Arrays.toString(jMapLauncher.getCommand()));
 116 
 117             Process jMapProcess = jMapProcessBuilder.start();


< prev index next >