本文整理汇总了Java中sun.management.ManagementFactoryHelper.getDiagnosticMXBean方法的典型用法代码示例。如果您正苦于以下问题:Java ManagementFactoryHelper.getDiagnosticMXBean方法的具体用法?Java ManagementFactoryHelper.getDiagnosticMXBean怎么用?Java ManagementFactoryHelper.getDiagnosticMXBean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.management.ManagementFactoryHelper
的用法示例。
在下文中一共展示了ManagementFactoryHelper.getDiagnosticMXBean方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVMOption
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
/**
* Returns value of VM option.
*
* @param name option's name
* @return value of option or {@code null}, if option doesn't exist
* @throws NullPointerException if name is null
*/
protected static String getVMOption(String name) {
Objects.requireNonNull(name);
HotSpotDiagnosticMXBean diagnostic
= ManagementFactoryHelper.getDiagnosticMXBean();
VMOption tmp;
try {
tmp = diagnostic.getVMOption(name);
} catch (IllegalArgumentException e) {
tmp = null;
}
return (tmp == null ? null : tmp.getValue());
}
示例2: main
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean hsd = ManagementFactoryHelper.getDiagnosticMXBean();
// 打印虚拟机的某个配置参数的值
VMOption vmo = hsd.getVMOption("UseCompressedOops");
System.out.println(vmo.getName() + " | " + vmo.getValue());
hsd.getDiagnosticOptions().stream().forEach(System.out::println);
}
示例3: main
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
System.out.println("Max memory= " + MAX_MEMORY + " bytes");
int obj_size = 0;
long seconds_to_run = 0;
if (args.length != 2) {
throw new RuntimeException("Object size argument must be supplied");
} else {
obj_size = Integer.parseInt(args[0]);
seconds_to_run = Integer.parseInt(args[1]);
}
System.out.println("Objects size= " + obj_size + " bytes");
System.out.println("Seconds to run=" + seconds_to_run);
int region_size =
Integer.parseInt(diagnostic.getVMOption("G1HeapRegionSize").getValue());
if (obj_size < (region_size / 2)) {
throw new RuntimeException("Object size " + obj_size +
" is not humongous with region size " + region_size);
}
ExecutorService executor =
Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory());
System.out.println("Starting " + THREAD_COUNT + " threads");
for (int i = 0; i < THREAD_COUNT; i++) {
executor.execute(new Runner(obj_size));
}
Thread.sleep(seconds_to_run * 1000);
executor.shutdownNow();
if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
System.err.println("Thread pool did not terminate after 10 seconds after shutdown");
}
}
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:39,代码来源:TestGreyReclaimedHumongousObjects.java
示例4: testingG1GC
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
public static boolean testingG1GC() {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("UseG1GC");
if (option.getValue().equals("false")) {
System.out.println("Skipping this test. It is only a G1 test.");
return false;
}
return true;
}
示例5: main
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
String expectedValue = getExpectedValue(args);
VMOption option = diagnostic.getVMOption("G1HeapRegionSize");
if (!expectedValue.equals(option.getValue())) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
}
}
示例6: getVMOption
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
/**
* Returns value of VM option.
*
* @param name option's name
* @return value of option or {@code null}, if option doesn't exist
* @throws NullPointerException if name is null
*/
public static String getVMOption(String name) {
String result;
HotSpotDiagnosticMXBean diagnostic
= ManagementFactoryHelper.getDiagnosticMXBean();
result = diagnostic.getVMOption(name).getValue();
return result;
}
示例7: main
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("UseG1GC");
if (option.getValue().equals("false")) {
System.out.println("Skipping this test. It is only a G1 test.");
return;
}
String expectedValue = getExpectedValue(args);
option = diagnostic.getVMOption("G1HeapRegionSize");
if (!expectedValue.equals(option.getValue())) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
}
}
示例8: getCompressedClassSpaceSize
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
private static long getCompressedClassSpaceSize() {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
return Long.parseLong(option.getValue());
}