Java Code Examples for sun.hotspot.WhiteBox#NMTMalloc
The following examples show how to use
sun.hotspot.WhiteBox#NMTMalloc .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MallocTestType.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type long memAlloc3 = wb.NMTMalloc(128 * 1024); long memAlloc2 = wb.NMTMalloc(256 * 1024); wb.NMTFree(memAlloc3); long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=512KB)"); // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 2
Source File: MallocTestType.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type long memAlloc3 = wb.NMTMalloc(128 * 1024); long memAlloc2 = wb.NMTMalloc(256 * 1024); wb.NMTFree(memAlloc3); long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=512KB)"); // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 3
Source File: MallocTestType.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type long memAlloc3 = wb.NMTMalloc(128 * 1024); long memAlloc2 = wb.NMTMalloc(256 * 1024); wb.NMTFree(memAlloc3); long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=512KB)"); // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 4
Source File: MallocTestType.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type long memAlloc3 = wb.NMTMalloc(128 * 1024); long memAlloc2 = wb.NMTMalloc(256 * 1024); wb.NMTFree(memAlloc3); long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=512KB)"); // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 5
Source File: MallocTestType.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type long memAlloc3 = wb.NMTMalloc(128 * 1024); long memAlloc2 = wb.NMTMalloc(256 * 1024); wb.NMTFree(memAlloc3); long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=512KB)"); // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 6
Source File: MallocTestType.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type long memAlloc3 = wb.NMTMalloc(128 * 1024); long memAlloc2 = wb.NMTMalloc(256 * 1024); wb.NMTFree(memAlloc3); long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=512KB)"); // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 7
Source File: ThreadedMallocTestType.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { public void run() { // Alloc memory using the WB api memAlloc1 = wb.NMTMalloc(128 * 1024); memAlloc2 = wb.NMTMalloc(256 * 1024); memAlloc3 = wb.NMTMalloc(512 * 1024); } }; allocThread.start(); allocThread.join(); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=896KB, committed=896KB)"); Thread freeThread = new Thread() { public void run() { // Free the memory allocated by NMTMalloc wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc3); } }; freeThread.start(); freeThread.join(); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 8
Source File: MallocTestType.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type long memAlloc3 = wb.NMTMalloc(128 * 1024); long memAlloc2 = wb.NMTMalloc(256 * 1024); wb.NMTFree(memAlloc3); long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=512KB)"); // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 9
Source File: MallocRoundingReportTest.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); long[] additionalBytes = {0, 1, 512, 650}; long[] kByteSize = {1024, 2048}; long mallocd_total = 0; for ( int i = 0; i < kByteSize.length; i++) { for (int j = 0; j < (additionalBytes.length); j++) { long curKB = kByteSize[i] + additionalBytes[j]; // round up/down to the nearest KB to match NMT reporting long numKB = (curKB % kByteSize[i] >= 512) ? ((curKB / K) + 1) : curKB / K; // Use WB API to alloc and free with the mtTest type mallocd_total = wb.NMTMalloc(curKB); // Run 'jcmd <pid> VM.native_memory summary', check for expected output // NMT does not track memory allocations less than 1KB, and rounds to the nearest KB String expectedOut = ("Test (reserved=" + numKB + "KB, committed=" + numKB + "KB)"); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldContain(expectedOut); wb.NMTFree(mallocd_total); // Run 'jcmd <pid> VM.native_memory summary', check for expected output pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); } } }
Example 10
Source File: ThreadedMallocTestType.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { public void run() { // Alloc memory using the WB api memAlloc1 = wb.NMTMalloc(128 * 1024); memAlloc2 = wb.NMTMalloc(256 * 1024); memAlloc3 = wb.NMTMalloc(512 * 1024); } }; allocThread.start(); allocThread.join(); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=896KB, committed=896KB)"); Thread freeThread = new Thread() { public void run() { // Free the memory allocated by NMTMalloc wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc3); } }; freeThread.start(); freeThread.join(); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 11
Source File: MallocRoundingReportTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); long[] additionalBytes = {0, 1, 512, 650}; long[] kByteSize = {1024, 2048}; long mallocd_total = 0; for ( int i = 0; i < kByteSize.length; i++) { for (int j = 0; j < (additionalBytes.length); j++) { long curKB = kByteSize[i] + additionalBytes[j]; // round up/down to the nearest KB to match NMT reporting long numKB = (curKB % kByteSize[i] >= 512) ? ((curKB / K) + 1) : curKB / K; // Use WB API to alloc and free with the mtTest type mallocd_total = wb.NMTMalloc(curKB); // Run 'jcmd <pid> VM.native_memory summary', check for expected output // NMT does not track memory allocations less than 1KB, and rounds to the nearest KB String expectedOut = ("Test (reserved=" + numKB + "KB, committed=" + numKB + "KB)"); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldContain(expectedOut); wb.NMTFree(mallocd_total); // Run 'jcmd <pid> VM.native_memory summary', check for expected output pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); } } }
Example 12
Source File: ThreadedMallocTestType.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { public void run() { // Alloc memory using the WB api memAlloc1 = wb.NMTMalloc(128 * 1024); memAlloc2 = wb.NMTMalloc(256 * 1024); memAlloc3 = wb.NMTMalloc(512 * 1024); } }; allocThread.start(); allocThread.join(); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=896KB, committed=896KB)"); Thread freeThread = new Thread() { public void run() { // Free the memory allocated by NMTMalloc wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc3); } }; freeThread.start(); freeThread.join(); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 13
Source File: MallocRoundingReportTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); long[] additionalBytes = {0, 1, 512, 650}; long[] kByteSize = {1024, 2048}; long mallocd_total = 0; for ( int i = 0; i < kByteSize.length; i++) { for (int j = 0; j < (additionalBytes.length); j++) { long curKB = kByteSize[i] + additionalBytes[j]; // round up/down to the nearest KB to match NMT reporting long numKB = (curKB % kByteSize[i] >= 512) ? ((curKB / K) + 1) : curKB / K; // Use WB API to alloc and free with the mtTest type mallocd_total = wb.NMTMalloc(curKB); // Run 'jcmd <pid> VM.native_memory summary', check for expected output // NMT does not track memory allocations less than 1KB, and rounds to the nearest KB String expectedOut = ("Test (reserved=" + numKB + "KB, committed=" + numKB + "KB)"); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldContain(expectedOut); wb.NMTFree(mallocd_total); // Run 'jcmd <pid> VM.native_memory summary', check for expected output pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); } } }
Example 14
Source File: ThreadedMallocTestType.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { public void run() { // Alloc memory using the WB api memAlloc1 = wb.NMTMalloc(128 * 1024); memAlloc2 = wb.NMTMalloc(256 * 1024); memAlloc3 = wb.NMTMalloc(512 * 1024); } }; allocThread.start(); allocThread.join(); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=896KB, committed=896KB)"); Thread freeThread = new Thread() { public void run() { // Free the memory allocated by NMTMalloc wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc3); } }; freeThread.start(); freeThread.join(); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 15
Source File: MallocRoundingReportTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); long[] additionalBytes = {0, 1, 512, 650}; long[] kByteSize = {1024, 2048}; long mallocd_total = 0; for ( int i = 0; i < kByteSize.length; i++) { for (int j = 0; j < (additionalBytes.length); j++) { long curKB = kByteSize[i] + additionalBytes[j]; // round up/down to the nearest KB to match NMT reporting long numKB = (curKB % kByteSize[i] >= 512) ? ((curKB / K) + 1) : curKB / K; // Use WB API to alloc and free with the mtTest type mallocd_total = wb.NMTMalloc(curKB); // Run 'jcmd <pid> VM.native_memory summary', check for expected output // NMT does not track memory allocations less than 1KB, and rounds to the nearest KB String expectedOut = ("Test (reserved=" + numKB + "KB, committed=" + numKB + "KB)"); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldContain(expectedOut); wb.NMTFree(mallocd_total); // Run 'jcmd <pid> VM.native_memory summary', check for expected output pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); } } }
Example 16
Source File: ThreadedMallocTestType.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { public void run() { // Alloc memory using the WB api memAlloc1 = wb.NMTMalloc(128 * 1024); memAlloc2 = wb.NMTMalloc(256 * 1024); memAlloc3 = wb.NMTMalloc(512 * 1024); } }; allocThread.start(); allocThread.join(); // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=896KB, committed=896KB)"); Thread freeThread = new Thread() { public void run() { // Free the memory allocated by NMTMalloc wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc3); } }; freeThread.start(); freeThread.join(); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 17
Source File: MallocRoundingReportTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); long[] additionalBytes = {0, 1, 512, 650}; long[] kByteSize = {1024, 2048}; long mallocd_total = 0; for ( int i = 0; i < kByteSize.length; i++) { for (int j = 0; j < (additionalBytes.length); j++) { long curKB = kByteSize[i] + additionalBytes[j]; // round up/down to the nearest KB to match NMT reporting long numKB = (curKB % kByteSize[i] >= 512) ? ((curKB / K) + 1) : curKB / K; // Use WB API to alloc and free with the mtTest type mallocd_total = wb.NMTMalloc(curKB); // Run 'jcmd <pid> VM.native_memory summary', check for expected output // NMT does not track memory allocations less than 1KB, and rounds to the nearest KB String expectedOut = ("Test (reserved=" + numKB + "KB, committed=" + numKB + "KB)"); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldContain(expectedOut); wb.NMTFree(mallocd_total); // Run 'jcmd <pid> VM.native_memory summary', check for expected output pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" }); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); } } }
Example 18
Source File: ThreadedMallocTestType.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { public void run() { // Alloc memory using the WB api memAlloc1 = wb.NMTMalloc(128 * 1024); memAlloc2 = wb.NMTMalloc(256 * 1024); memAlloc3 = wb.NMTMalloc(512 * 1024); } }; allocThread.start(); allocThread.join(); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=896KB, committed=896KB)"); Thread freeThread = new Thread() { public void run() { // Free the memory allocated by NMTMalloc wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc3); } }; freeThread.start(); freeThread.join(); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }
Example 19
Source File: ThreadedMallocTestType.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { OutputAnalyzer output; final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { public void run() { // Alloc memory using the WB api memAlloc1 = wb.NMTMalloc(128 * 1024); memAlloc2 = wb.NMTMalloc(256 * 1024); memAlloc3 = wb.NMTMalloc(512 * 1024); } }; allocThread.start(); allocThread.join(); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } // Run 'jcmd <pid> VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=896KB, committed=896KB)"); Thread freeThread = new Thread() { public void run() { // Free the memory allocated by NMTMalloc wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc3); } }; freeThread.start(); freeThread.join(); // Use WB API to ensure that all data has been merged before we continue if (!wb.NMTWaitForDataMerge()) { throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); }