Java Code Examples for sun.hotspot.WhiteBox#NMTWaitForDataMerge

The following examples show how to use sun.hotspot.WhiteBox#NMTWaitForDataMerge . 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: ReleaseCommittedMemory.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  long reserveSize = 256 * 1024;
  long addr;

  addr = wb.NMTReserveMemory(reserveSize);
  wb.NMTCommitMemory(addr, 128*1024);
  wb.NMTReleaseMemory(addr, reserveSize);
  wb.NMTWaitForDataMerge();
}
 
Example 2
Source File: MallocTestType.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 3
Source File: ReleaseCommittedMemory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  long reserveSize = 256 * 1024;
  long addr;

  addr = wb.NMTReserveMemory(reserveSize);
  wb.NMTCommitMemory(addr, 128*1024);
  wb.NMTReleaseMemory(addr, reserveSize);
  wb.NMTWaitForDataMerge();
}
 
Example 4
Source File: MallocTestType.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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 5
Source File: ThreadedMallocTestType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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 6
Source File: ThreadedMallocTestType.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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=");
}