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(); | 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 if (!largeHeapScanner.hasNext()) { 94 throw new RuntimeException ("Test failed: could not open largeHeapScanner."); 95 } 96 while ((pidstring = largeHeapScanner.findInLine("PID\\[[0-9].*\\]")) == null) { 97 Thread.sleep(500); 98 } 99 int pid = Integer.parseInt(pidstring.substring(4, 100 pidstring.length() - 1)); 101 System.out.println("Extracted pid: " + pid); 102 103 JDKToolLauncher jMapLauncher = JDKToolLauncher 104 .createUsingTestJDK("jhsdb"); 105 jMapLauncher.addToolArg("jmap"); 106 jMapLauncher.addToolArg("--binaryheap"); 107 jMapLauncher.addToolArg("--pid"); 108 jMapLauncher.addToolArg(String.valueOf(pid)); 109 110 ProcessBuilder jMapProcessBuilder = new ProcessBuilder( 111 jMapLauncher.getCommand()); 112 System.out.println("jmap command: " 113 + Arrays.toString(jMapLauncher.getCommand())); 114 115 Process jMapProcess = jMapProcessBuilder.start(); |