Java Code Examples for java.lang.management.MemoryPoolMXBean#getUsageThresholdCount()

The following examples show how to use java.lang.management.MemoryPoolMXBean#getUsageThresholdCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UsageThresholdIncreasedTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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());
}
 
Example 2
Source File: UsageThresholdNotExceededTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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());
}
 
Example 3
Source File: UsageThresholdExceededTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 4
Source File: CodeCacheUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}