當前位置: 首頁>>代碼示例>>Java>>正文


Java MemoryPoolMXBean.getCollectionUsage方法代碼示例

本文整理匯總了Java中java.lang.management.MemoryPoolMXBean.getCollectionUsage方法的典型用法代碼示例。如果您正苦於以下問題:Java MemoryPoolMXBean.getCollectionUsage方法的具體用法?Java MemoryPoolMXBean.getCollectionUsage怎麽用?Java MemoryPoolMXBean.getCollectionUsage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.management.MemoryPoolMXBean的用法示例。


在下文中一共展示了MemoryPoolMXBean.getCollectionUsage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
@Override
public void run() {
    List<GarbageCollectorMXBean> garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
    GarbageCollectorMXBean garbageCollectorMXBean = CollectionUtils.findFirst(garbageCollectorMXBeans, new Spec<GarbageCollectorMXBean>() {
        @Override
        public boolean isSatisfiedBy(GarbageCollectorMXBean mbean) {
            return mbean.getName().equals(garbageCollector);
        }
    });

    List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
    for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
        String pool = memoryPoolMXBean.getName();
        if (memoryPools.contains(pool)) {
            GarbageCollectionEvent event = new GarbageCollectionEvent(System.currentTimeMillis(), memoryPoolMXBean.getCollectionUsage(), garbageCollectorMXBean.getCollectionCount());
            events.get(pool).slideAndInsert(event);
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:20,代碼來源:GarbageCollectionCheck.java

示例2: poolSummaries

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
/**
 * Returns a summary information about the memory pools.
 */
public static String poolSummaries() {
    // Why ? list-archive?4273859
    // How ? http://stackoverflow.com/questions/697336/how-do-i-programmatically-find-out-my-permgen-space-usage
    //       http://stackoverflow.com/questions/8356416/xxmaxpermsize-with-or-without-xxpermsize
    StringBuilder sb = new StringBuilder();
    Iterator<MemoryPoolMXBean> iter =
            ManagementFactory.getMemoryPoolMXBeans().iterator();
    while (iter.hasNext()) {
        MemoryPoolMXBean item = iter.next();
        String name = item.getName();
        MemoryType type = item.getType();
        MemoryUsage usage = item.getUsage();
        MemoryUsage peak = item.getPeakUsage();
        MemoryUsage collections = item.getCollectionUsage();
        sb.append(String.format("Memory pool name: " + name
                                + ", type: " + type
                                + ", usage: " + usage
                                + ", peak: " + peak
                                + ", collections: " + collections
                                + "\n"));
    }
    return sb.toString();
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:27,代碼來源:Memory.java


注:本文中的java.lang.management.MemoryPoolMXBean.getCollectionUsage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。