本文整理汇总了Java中com.sun.management.GarbageCollectorMXBean.getCollectionCount方法的典型用法代码示例。如果您正苦于以下问题:Java GarbageCollectorMXBean.getCollectionCount方法的具体用法?Java GarbageCollectorMXBean.getCollectionCount怎么用?Java GarbageCollectorMXBean.getCollectionCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.management.GarbageCollectorMXBean
的用法示例。
在下文中一共展示了GarbageCollectorMXBean.getCollectionCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateStampsAndStoreDifference
import com.sun.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public void updateStampsAndStoreDifference( /*out*/ final SingleIterationResult iterationResult ) {
long totalGcCollectionCount = 0;
long totalGcCollectionTime = 0;
for( final GarbageCollectorMXBean gcBean : gcMXBeans ) {
totalGcCollectionCount += gcBean.getCollectionCount();
totalGcCollectionTime += gcBean.getCollectionTime();
}
final long bytesAllocatedByThread = threadMXBean.getThreadAllocatedBytes( benchmarkThreadId );
iterationResult.fill(
totalGcCollectionTime - gcCollectionTime,
totalGcCollectionCount - gcCollectionCount,
bytesAllocatedByThread - memoryAllocatedByThreadBytes
);
this.gcCollectionCount = totalGcCollectionCount;
this.gcCollectionTime = totalGcCollectionTime;
this.memoryAllocatedByThreadBytes = bytesAllocatedByThread;
}
示例2: storeCurrentStamps
import com.sun.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public void storeCurrentStamps() {
long collectionCounts = 0;
long collectionTimes = 0;
for( final GarbageCollectorMXBean gcBean : gcMXBeans ) {
collectionCounts += gcBean.getCollectionCount();
collectionTimes += gcBean.getCollectionTime();
}
this.gcCollectionCount = collectionCounts;
this.gcCollectionTime = collectionTimes;
this.memoryAllocatedByThreadBytes = threadMXBean.getThreadAllocatedBytes( benchmarkThreadId );
}
示例3: getStat
import com.sun.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public MemoryPoolStat getStat() throws java.io.IOException {
long usageThreshold = (pool.isUsageThresholdSupported()
? pool.getUsageThreshold()
: -1);
long collectThreshold = (pool.isCollectionUsageThresholdSupported()
? pool.getCollectionUsageThreshold()
: -1);
long lastGcStartTime = 0;
long lastGcEndTime = 0;
MemoryUsage beforeGcUsage = null;
MemoryUsage afterGcUsage = null;
long gcId = 0;
if (lastGcInfo != null) {
gcId = lastGcInfo.getId();
lastGcStartTime = lastGcInfo.getStartTime();
lastGcEndTime = lastGcInfo.getEndTime();
beforeGcUsage = lastGcInfo.getMemoryUsageBeforeGc().get(poolName);
afterGcUsage = lastGcInfo.getMemoryUsageAfterGc().get(poolName);
}
Set<Map.Entry<ObjectName,Long>> set = gcMBeans.entrySet();
for (Map.Entry<ObjectName,Long> e : set) {
GarbageCollectorMXBean gc =
client.getMXBean(e.getKey(),
com.sun.management.GarbageCollectorMXBean.class);
Long gcCount = e.getValue();
Long newCount = gc.getCollectionCount();
if (newCount > gcCount) {
gcMBeans.put(e.getKey(), new Long(newCount));
lastGcInfo = gc.getLastGcInfo();
if (lastGcInfo.getEndTime() > lastGcEndTime) {
gcId = lastGcInfo.getId();
lastGcStartTime = lastGcInfo.getStartTime();
lastGcEndTime = lastGcInfo.getEndTime();
beforeGcUsage = lastGcInfo.getMemoryUsageBeforeGc().get(poolName);
afterGcUsage = lastGcInfo.getMemoryUsageAfterGc().get(poolName);
assert(beforeGcUsage != null);
assert(afterGcUsage != null);
}
}
}
MemoryUsage usage = pool.getUsage();
return new MemoryPoolStat(poolName,
usageThreshold,
usage,
gcId,
lastGcStartTime,
lastGcEndTime,
collectThreshold,
beforeGcUsage,
afterGcUsage);
}
示例4: getStat
import com.sun.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public MemoryPoolStat getStat() throws java.io.IOException {
long usageThreshold = (pool.isUsageThresholdSupported()
? pool.getUsageThreshold()
: -1);
long collectThreshold = (pool.isCollectionUsageThresholdSupported()
? pool.getCollectionUsageThreshold()
: -1);
long lastGcStartTime = 0;
long lastGcEndTime = 0;
MemoryUsage beforeGcUsage = null;
MemoryUsage afterGcUsage = null;
long gcId = 0;
if (lastGcInfo != null) {
gcId = lastGcInfo.getId();
lastGcStartTime = lastGcInfo.getStartTime();
lastGcEndTime = lastGcInfo.getEndTime();
beforeGcUsage = lastGcInfo.getMemoryUsageBeforeGc().get(poolName);
afterGcUsage = lastGcInfo.getMemoryUsageAfterGc().get(poolName);
}
Set<Map.Entry<ObjectName,Long>> set = gcMBeans.entrySet();
for (Map.Entry<ObjectName,Long> e : set) {
GarbageCollectorMXBean gc =
client.getMXBean(e.getKey(),
com.sun.management.GarbageCollectorMXBean.class);
Long gcCount = e.getValue();
Long newCount = gc.getCollectionCount();
if (newCount > gcCount) {
gcMBeans.put(e.getKey(), newCount);
lastGcInfo = gc.getLastGcInfo();
if (lastGcInfo.getEndTime() > lastGcEndTime) {
gcId = lastGcInfo.getId();
lastGcStartTime = lastGcInfo.getStartTime();
lastGcEndTime = lastGcInfo.getEndTime();
beforeGcUsage = lastGcInfo.getMemoryUsageBeforeGc().get(poolName);
afterGcUsage = lastGcInfo.getMemoryUsageAfterGc().get(poolName);
assert(beforeGcUsage != null);
assert(afterGcUsage != null);
}
}
}
MemoryUsage usage = pool.getUsage();
return new MemoryPoolStat(poolName,
usageThreshold,
usage,
gcId,
lastGcStartTime,
lastGcEndTime,
collectThreshold,
beforeGcUsage,
afterGcUsage);
}
示例5: getStat
import com.sun.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public MemoryPoolStat getStat() throws java.io.IOException {
long usageThreshold = (pool.isUsageThresholdSupported()
? pool.getUsageThreshold()
: -1);
long collectThreshold = (pool.isCollectionUsageThresholdSupported()
? pool.getCollectionUsageThreshold()
: -1);
long lastGcStartTime = 0;
long lastGcEndTime = 0;
MemoryUsage beforeGcUsage = null;
MemoryUsage afterGcUsage = null;
long gcId = 0;
if (lastGcInfo != null) {
gcId = lastGcInfo.getId();
lastGcStartTime = lastGcInfo.getStartTime();
lastGcEndTime = lastGcInfo.getEndTime();
beforeGcUsage = lastGcInfo.getMemoryUsageBeforeGc().get(poolName);
afterGcUsage = lastGcInfo.getMemoryUsageAfterGc().get(poolName);
}
Set<Map.Entry<ObjectName,Long>> set = gcMBeans.entrySet();
for (Map.Entry<ObjectName,Long> e : set) {
GarbageCollectorMXBean gc =
client.getMXBean(e.getKey(),
com.sun.management.GarbageCollectorMXBean.class);
Long gcCount = e.getValue();
Long newCount = gc.getCollectionCount();
if (newCount > gcCount) {
gcMBeans.put(e.getKey(), new Long(newCount));
lastGcInfo = gc.getLastGcInfo();
if (lastGcInfo.getEndTime() > lastGcEndTime) {
gcId = lastGcInfo.getId();
lastGcStartTime = lastGcInfo.getStartTime();
lastGcEndTime = lastGcInfo.getEndTime();
beforeGcUsage = lastGcInfo.getMemoryUsageBeforeGc().get(poolName);
afterGcUsage = lastGcInfo.getMemoryUsageAfterGc().get(poolName);
assert(beforeGcUsage != null);
assert(afterGcUsage != null);
}
}
}
MemoryUsage usage = pool.getUsage();
return new MemoryPoolStat(poolName,
usageThreshold,
usage,
gcId,
lastGcStartTime,
lastGcEndTime,
collectThreshold,
beforeGcUsage,
afterGcUsage);
}