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=");
  }
Ejemplo n.º 2
0
  protected void prepare() throws Exception {
    ProcessBuilder pb = createJarProcessBuilder("cf", "foo.jar", "Foo.class", "Bar.class");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    dump(output, "ctw-foo.jar");
    output.shouldHaveExitValue(0);

    pb = createJarProcessBuilder("cf", "bar.jar", "Foo.class", "Bar.class");
    output = new OutputAnalyzer(pb.start());
    dump(output, "ctw-bar.jar");
    output.shouldHaveExitValue(0);
  }
  public static void main(String args[]) throws Exception {

    ProcessBuilder pb =
        ProcessTools.createJavaProcessBuilder(
            "-showversion",
            "-XX:+UseParallelGC",
            "-XX:+UseAdaptiveGCBoundary",
            "-XX:+PrintCommandLineFlags",
            SystemGCCaller.class.getName());

    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    output.shouldContain("+UseAdaptiveGCBoundary");

    output.shouldNotContain("error");

    output.shouldHaveExitValue(0);
  }
Ejemplo n.º 4
0
 private static void verifyContainsNoGCIDs(OutputAnalyzer output) {
   output.shouldNotMatch("^#[0-9]+: \\[");
   output.shouldHaveExitValue(0);
 }
Ejemplo n.º 5
0
 private static void verifyContainsGCIDs(OutputAnalyzer output) {
   output.shouldMatch("^#0: \\[");
   output.shouldMatch("^#1: \\[");
   output.shouldHaveExitValue(0);
 }