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


Java GarbageCollectorMXBean.getCollectionCount方法代码示例

本文整理汇总了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;
}
 
开发者ID:cheremin,项目名称:scalarization,代码行数:22,代码来源:AllocationBenchmarkBuilder.java

示例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 );
}
 
开发者ID:cheremin,项目名称:scalarization,代码行数:13,代码来源:AllocationBenchmarkBuilder.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:54,代码来源:MemoryPoolProxy.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:MemoryPoolProxy.java

示例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);
}
 
开发者ID:toomanyopenfiles,项目名称:jmxmon,代码行数:54,代码来源:MemoryPoolProxy.java


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