I want to build a MemoryWarningSystem as described in many articles: e.g. as in http://www.javaspecialists.eu/archive/Issue092.html.
Therefore, I want to identify the tenured space like this:
private MemoryPoolMXBean findTenuredGenPool() {
for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
if(pool is tenured space)
return tenured
}
}
I have seen two different ways to identify tenured space
pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported()
" Problem with 1: What about CMS Old Gen? What about other tenured spaces? Should I add all of them to the List of Tenured Names?
Problem with 2: Is this a "safe" way of retrieving the tenured space? Is it reliable?
Thanks!
For HotSpot JVM possible memory pool name for old space
Tenured Gen
PS Old Gen
CMS Old Gen
G1 Old Gen
For JRockit
Old Space
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With