use*_*885 5 java memory garbage-collection
我想构建一个MemoryWarningSystem,如许多文章所述:例如http://www.javaspecialists.eu/archive/Issue092.html.
因此,我想确定这样的终身空间:
private MemoryPoolMXBean findTenuredGenPool() {
for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
if(pool is tenured space)
return tenured
}
}
Run Code Online (Sandbox Code Playgroud)
我已经看到了两种不同的方法来识别终身空间
pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported()"问题1:CMS Old Gen怎么样?其他终身空间怎么样?我应该将所有这些添加到终身名单列表中吗?
问题2:这是检索终身空间的"安全"方式吗?它可靠吗?
谢谢!
对于 HotSpot JVM 旧空间可能的内存池名称
Tenured GenPS Old GenCMS Old GenG1 Old Gen对于 JRockit
Old Space