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