本文整理匯總了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());
}
示例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());
}
示例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());
}
示例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);
}