Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify Tenured Space

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

  1. Check if pool name equals to "PS Old Gen" and/or "Tenured Gen".
  2. Check whether "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!

like image 285
user1654885 Avatar asked Nov 13 '22 07:11

user1654885


1 Answers

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
like image 126
Alexey Ragozin Avatar answered Nov 14 '22 22:11

Alexey Ragozin