当前位置: 首页>>代码示例>>Java>>正文


Java WhiteBox.NMTMalloc方法代码示例

本文整理汇总了Java中sun.hotspot.WhiteBox.NMTMalloc方法的典型用法代码示例。如果您正苦于以下问题:Java WhiteBox.NMTMalloc方法的具体用法?Java WhiteBox.NMTMalloc怎么用?Java WhiteBox.NMTMalloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.hotspot.WhiteBox的用法示例。


在下文中一共展示了WhiteBox.NMTMalloc方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
  OutputAnalyzer output;
  WhiteBox wb = WhiteBox.getWhiteBox();

  // Grab my own PID
  String pid = Long.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=");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:MallocTestType.java

示例2: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
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=");
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:27,代码来源:MallocTestType.java

示例3: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
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=");
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:36,代码来源:MallocTestType.java

示例4: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
  OutputAnalyzer output;
  final WhiteBox wb = WhiteBox.getWhiteBox();

  // Grab my own PID
  String pid = Long.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=");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:ThreadedMallocTestType.java

示例5: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    OutputAnalyzer output;
    WhiteBox wb = WhiteBox.getWhiteBox();

    // Grab my own PID
    String pid = Long.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=");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:MallocRoundingReportTest.java

示例6: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
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=");
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:41,代码来源:ThreadedMallocTestType.java

示例7: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
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=");
        }
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:36,代码来源:MallocRoundingReportTest.java

示例8: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
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 memAlloc1 = wb.NMTMalloc(512 * 1024);

  // 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 baseline'
  pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline"});
  pb.start();

  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");
  }

  // Run 'jcmd <pid> VM.native_memory detail.diff'
  pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail.diff"});
  output = new OutputAnalyzer(pb.start());


  // 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");
  }

  // above malloc callsite should report 0
  output = new OutputAnalyzer(pb.start());
  output.shouldContain("(malloc=0");
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:41,代码来源:JcmdDiffCallsite.java

示例9: main

import sun.hotspot.WhiteBox; //导入方法依赖的package包/类
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=");
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:51,代码来源:ThreadedMallocTestType.java


注:本文中的sun.hotspot.WhiteBox.NMTMalloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。