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


Java MemoryPoolMXBean.isUsageThresholdSupported方法代碼示例

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


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

示例1: main

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
public static void main(String[] args) {
    List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
    boolean verified = false;
    for (MemoryPoolMXBean i : pools) {
        if ((i.getUsage().getMax() >= TWO_G)
                && i.isUsageThresholdSupported()) {
            i.setUsageThreshold(TWO_G);
            if(i.getUsageThreshold() != TWO_G)
                throw new RuntimeException("Usage threshold for"
                        + " pool '" + i.getName() + "' is " + i.getUsageThreshold()
                        + " and not equal to 2GB");
            verified = true;
        }
    }
    System.out.println("Ability to use big heap thresholds has "
            + (verified ? "" : "NOT ") + "been verified");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:LargeHeapThresholdTest.java

示例2: findPool

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
private static MemoryPoolMXBean findPool()
{
	MemoryPoolMXBean ret = null;
	for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
		if (pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported()) {
			ret = pool;
		}
	}
	// we do something when we reached 99.9% of memory usage
	// when we get to this point gc was unable to recover memory.
	ret.setCollectionUsageThreshold((long) Math.floor(ret.getUsage().getMax() * 0.999));

	return (ret);
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:15,代碼來源:MemoryMonitor.java

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