本文整理汇总了Java中com.sun.management.GcInfo.from方法的典型用法代码示例。如果您正苦于以下问题:Java GcInfo.from方法的具体用法?Java GcInfo.from怎么用?Java GcInfo.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.management.GcInfo
的用法示例。
在下文中一共展示了GcInfo.from方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printGcInfo
import com.sun.management.GcInfo; //导入方法依赖的package包/类
private static void printGcInfo(CompositeData cd) throws Exception {
GcInfo info = GcInfo.from(cd);
System.out.print("GC #" + info.getId());
System.out.print(" start:" + info.getStartTime());
System.out.print(" end:" + info.getEndTime());
System.out.println(" (" + info.getDuration() + "ms)");
Map<String,MemoryUsage> usage = info.getMemoryUsageBeforeGc();
for (Map.Entry<String,MemoryUsage> entry : usage.entrySet()) {
String poolname = entry.getKey();
MemoryUsage busage = entry.getValue();
MemoryUsage ausage = info.getMemoryUsageAfterGc().get(poolname);
if (ausage == null) {
throw new RuntimeException("After Gc Memory does not exist" +
" for " + poolname);
}
System.out.println("Usage for pool " + poolname);
System.out.println(" Before GC: " + busage);
System.out.println(" After GC: " + ausage);
}
}
示例2: getGcInfo
import com.sun.management.GcInfo; //导入方法依赖的package包/类
public static GcInfo getGcInfo(CompositeData cd) {
CompositeData gcInfoData = (CompositeData) cd.get(GC_INFO);
return GcInfo.from(gcInfoData);
}