void install() {
Preconditions.checkState(!installed, "RetainedHeapLimiter installed twice");
installed = true;
List<GarbageCollectorMXBean> gcbeans = ManagementFactory.getGarbageCollectorMXBeans();
boolean foundTenured = false;
// Examine all collectors and register for notifications from those which collect the tenured
// space. Normally there is one such collector.
for (GarbageCollectorMXBean gcbean : gcbeans) {
boolean collectsTenured = false;
for (String name : gcbean.getMemoryPoolNames()) {
collectsTenured |= isTenuredSpace(name);
}
if (collectsTenured) {
foundTenured = true;
NotificationEmitter emitter = (NotificationEmitter) gcbean;
emitter.addNotificationListener(this, null, null);
}
}
if (!foundTenured) {
throw new IllegalStateException(
"Can't find tenured space; update this class for a new collector");
}
}
RetainedHeapLimiter.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:bazel
作者:
评论列表
文章目录