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


Java MemoryPoolMXBean.getUsageThresholdCount方法代碼示例

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


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

示例1: runTest

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
protected void runTest() {
    long headerSize = CodeCacheUtils.getHeaderSize(btype);
    long allocationUnit = Math.max(0, CodeCacheUtils.MIN_ALLOCATION - headerSize);
    MemoryPoolMXBean bean = btype.getMemoryPool();
    long initialCount = bean.getUsageThresholdCount();
    long initialSize = bean.getUsage().getUsed();
    bean.setUsageThreshold(initialSize + THRESHOLD_STEP);
    for (int i = 0; i < ALLOCATION_STEP - 1; i++) {
        CodeCacheUtils.WB.allocateCodeBlob(allocationUnit, btype.id);
    }
    // Usage threshold check is triggered by GC cycle, so, call it
    CodeCacheUtils.WB.fullGC();
    checkUsageThresholdCount(bean, initialCount);
    long filledSize = bean.getUsage().getUsed();
    bean.setUsageThreshold(filledSize + THRESHOLD_STEP);
    for (int i = 0; i < ALLOCATION_STEP - 1; i++) {
        CodeCacheUtils.WB.allocateCodeBlob(allocationUnit, btype.id);
    }
    CodeCacheUtils.WB.fullGC();
    checkUsageThresholdCount(bean, initialCount);
    System.out.println("INFO: Case finished successfully for " + bean.getName());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:UsageThresholdIncreasedTest.java

示例2: runTest

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
protected void runTest() {
    MemoryPoolMXBean bean = btype.getMemoryPool();
    long initialThresholdCount = bean.getUsageThresholdCount();
    long initialUsage = bean.getUsage().getUsed();

    bean.setUsageThreshold(initialUsage + 1 + CodeCacheUtils.MIN_ALLOCATION);
    long size = CodeCacheUtils.getHeaderSize(btype);

    CodeCacheUtils.WB.allocateCodeBlob(Math.max(0, CodeCacheUtils.MIN_ALLOCATION
            - size), btype.id);
    // a gc cycle triggers usage threshold recalculation
    CodeCacheUtils.WB.fullGC();
    CodeCacheUtils.assertEQorGTE(btype, bean.getUsageThresholdCount(), initialThresholdCount,
            String.format("Usage threshold was hit: %d times for %s. "
                    + "Threshold value: %d with current usage: %d",
                    bean.getUsageThresholdCount(), bean.getName(),
                    bean.getUsageThreshold(), bean.getUsage().getUsed()));
    System.out.println("INFO: Case finished successfully for " + bean.getName());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:UsageThresholdNotExceededTest.java

示例3: runTest

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
protected void runTest() {
    MemoryPoolMXBean bean = btype.getMemoryPool();
    long oldValue = bean.getUsageThresholdCount();
    for (int i = 0; i < iterations; i++) {
        CodeCacheUtils.hitUsageThreshold(bean, btype);
    }
    CodeCacheUtils.assertEQorGTE(btype, bean.getUsageThresholdCount(), oldValue + iterations,
            "Unexpected threshold usage count");
    System.out.printf("INFO: Scenario finished successfully for %s%n", bean.getName());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:UsageThresholdExceededTest.java

示例4: hitUsageThreshold

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
public static final void hitUsageThreshold(MemoryPoolMXBean bean,
        BlobType btype) {
    long initialSize = bean.getUsage().getUsed();
    bean.setUsageThreshold(initialSize + 1);
    long usageThresholdCount = bean.getUsageThresholdCount();
    long addr = WB.allocateCodeBlob(1, btype.id);
    WB.fullGC();
    Utils.waitForCondition(()
            -> bean.getUsageThresholdCount() == usageThresholdCount + 1);
    WB.freeCodeBlob(addr);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:CodeCacheUtils.java


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