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


Java MemoryPoolMXBean.resetPeakUsage方法代碼示例

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


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

示例1: doMemoryPoolMXBeanTest

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
private final int doMemoryPoolMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- MemoryPoolMXBean") ;

    try {
        ObjectName filterName =
                new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE
                + ",*");
        Set<ObjectName> onSet = mbsc.queryNames(filterName, null);

        for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) {
            ObjectName memoryPoolName = iter.next() ;
            System.out.println("-------- " + memoryPoolName) ;
            MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryPoolName);
            errorCount += checkNonEmpty(mbInfo);
            System.out.println("getMBeanInfo\t\t" + mbInfo);
            MemoryPoolMXBean memoryPool = null;

            memoryPool =
                    JMX.newMXBeanProxy(mbsc,
                    memoryPoolName,
                    MemoryPoolMXBean.class,
                    true) ;
            System.out.println("getCollectionUsage\t\t"
                    + memoryPool.getCollectionUsage());
            System.out.println("getMemoryManagerNames\t\t"
                    + Arrays.deepToString(memoryPool.getMemoryManagerNames()));
            System.out.println("getName\t\t"
                    + memoryPool.getName());
            System.out.println("getPeakUsage\t\t"
                    + memoryPool.getPeakUsage());
            System.out.println("getType\t\t"
                    + memoryPool.getType());
            System.out.println("getUsage\t\t"
                    + memoryPool.getUsage());
            System.out.println("isValid\t\t"
                    + memoryPool.isValid());
            boolean supported = memoryPool.isUsageThresholdSupported() ;
            System.out.println("isUsageThresholdSupported\t\t"
                    + supported);

            if ( supported ) {
                System.out.println("getUsageThreshold\t\t"
                        + memoryPool.getUsageThreshold());
                System.out.println("isUsageThresholdExceeded\t\t"
                        + memoryPool.isUsageThresholdExceeded());
                System.out.println("getUsageThresholdCount\t\t"
                        + memoryPool.getUsageThresholdCount());
            }

            supported = memoryPool.isCollectionUsageThresholdSupported() ;
            System.out.println("isCollectionUsageThresholdSupported\t\t"
                    + supported);

            if ( supported ) {
                System.out.println("getCollectionUsageThreshold\t\t"
                        + memoryPool.getCollectionUsageThreshold());
                System.out.println("getCollectionUsageThresholdCount\t\t"
                        + memoryPool.getCollectionUsageThresholdCount());
                System.out.println("isCollectionUsageThresholdExceeded\t\t"
                        + memoryPool.isCollectionUsageThresholdExceeded());
            }

            memoryPool.resetPeakUsage();
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:76,代碼來源:MXBeanInteropTest1.java


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