Java Code Examples for sun.hotspot.WhiteBox#NMTGetHashSize
The following examples show how to use
sun.hotspot.WhiteBox#NMTGetHashSize .
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: MallocSiteHashOverflow.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { // Size of entries based on malloc tracking header defined in mallocTracker.hpp // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket long entries = 257; OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); int MAX_HASH_SIZE = wb.NMTGetHashSize(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Verify that current tracking level is "detail" pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Native Memory Tracking Statistics"); // Attempt to cause NMT to downgrade tracking level by allocating small amounts // of memory with random pseudo call stack int pc = 1; for (int i = 0; i < entries; i++) { long addr = wb.NMTMallocWithPseudoStack(1, pc); if (addr == 0) { throw new RuntimeException("NMTMallocWithPseudoStack: out of memory"); } // We free memory here since it doesn't affect pseudo malloc alloc site hash table entries wb.NMTFree(addr); pc += MAX_HASH_SIZE; if (i == entries) { // Verify that tracking has been downgraded pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Tracking level has been downgraded due to lack of resources"); } } }
Example 2
Source File: MallocSiteHashOverflow.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { // Size of entries based on malloc tracking header defined in mallocTracker.hpp // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket long entries = 257; OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); int MAX_HASH_SIZE = wb.NMTGetHashSize(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Verify that current tracking level is "detail" pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Native Memory Tracking Statistics"); // Attempt to cause NMT to downgrade tracking level by allocating small amounts // of memory with random pseudo call stack int pc = 1; for (int i = 0; i < entries; i++) { long addr = wb.NMTMallocWithPseudoStack(1, pc); if (addr == 0) { throw new RuntimeException("NMTMallocWithPseudoStack: out of memory"); } // We free memory here since it doesn't affect pseudo malloc alloc site hash table entries wb.NMTFree(addr); pc += MAX_HASH_SIZE; if (i == entries) { // Verify that tracking has been downgraded pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Tracking level has been downgraded due to lack of resources"); } } }
Example 3
Source File: MallocSiteHashOverflow.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { // Size of entries based on malloc tracking header defined in mallocTracker.hpp // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket long entries = 257; OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); int MAX_HASH_SIZE = wb.NMTGetHashSize(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Verify that current tracking level is "detail" pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Native Memory Tracking Statistics"); // Attempt to cause NMT to downgrade tracking level by allocating small amounts // of memory with random pseudo call stack int pc = 1; for (int i = 0; i < entries; i++) { long addr = wb.NMTMallocWithPseudoStack(1, pc); if (addr == 0) { throw new RuntimeException("NMTMallocWithPseudoStack: out of memory"); } // We free memory here since it doesn't affect pseudo malloc alloc site hash table entries wb.NMTFree(addr); pc += MAX_HASH_SIZE; if (i == entries) { // Verify that tracking has been downgraded pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Tracking level has been downgraded due to lack of resources"); } } }
Example 4
Source File: MallocSiteHashOverflow.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { // Size of entries based on malloc tracking header defined in mallocTracker.hpp // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket long entries = 257; OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); int MAX_HASH_SIZE = wb.NMTGetHashSize(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Verify that current tracking level is "detail" pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Native Memory Tracking Statistics"); // Attempt to cause NMT to downgrade tracking level by allocating small amounts // of memory with random pseudo call stack int pc = 1; for (int i = 0; i < entries; i++) { long addr = wb.NMTMallocWithPseudoStack(1, pc); if (addr == 0) { throw new RuntimeException("NMTMallocWithPseudoStack: out of memory"); } // We free memory here since it doesn't affect pseudo malloc alloc site hash table entries wb.NMTFree(addr); pc += MAX_HASH_SIZE; if (i == entries) { // Verify that tracking has been downgraded pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Tracking level has been downgraded due to lack of resources"); } } }
Example 5
Source File: MallocSiteHashOverflow.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { // Size of entries based on malloc tracking header defined in mallocTracker.hpp // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket long entries = 257; OutputAnalyzer output; WhiteBox wb = WhiteBox.getWhiteBox(); int MAX_HASH_SIZE = wb.NMTGetHashSize(); // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Verify that current tracking level is "detail" pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Native Memory Tracking Statistics"); // Attempt to cause NMT to downgrade tracking level by allocating small amounts // of memory with random pseudo call stack int pc = 1; for (int i = 0; i < entries; i++) { long addr = wb.NMTMallocWithPseudoStack(1, pc); if (addr == 0) { throw new RuntimeException("NMTMallocWithPseudoStack: out of memory"); } // We free memory here since it doesn't affect pseudo malloc alloc site hash table entries wb.NMTFree(addr); pc += MAX_HASH_SIZE; if (i == entries) { // Verify that tracking has been downgraded pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Tracking level has been downgraded due to lack of resources"); } } }