My Oracle Support Banner

MemoryPoolMXBean Pool For G1 Pools Report "undefined" Values (Doc ID 2411961.1)

Last updated on JULY 06, 2018

Applies to:

Java SE JDK and JRE - Version 8 and later
Information in this document applies to any platform.

Goal

We are using the G1 Garbage Collection (see [1] for options used). Using the JVM APIs,
the following two memory pools for "max" (see [2]) return -1 (undefined).
1. G1 Eden Space Type
2. G1 Survivor Space

Questions:
1. Why does getMax() return the undefined value for G1 (see [2] below). We use
this for CMS and do not have the same issue.
2. Are there known defects in this area, if so, please provide the bugid(s)?
3. Are there other options/workarounds for getting the "max" for the above two memory pools?

We use ManagementFactory.getMemoryPoolMXBeans() [see [3]] to get the list of MemoryPoolMXBean
pools, and for each MemoryPoolMXBean, we call getUsage() [see [4]) which returns a
MemoryUsage object. The getMax() on this MemoryUsage it returns -1 [for G1 Eden Space
and G1 Survivor Space].

[1] G1 options used
-XX:+UseG1GC -XX:MaxGCPauseMillis=200

[2] https://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryUsage.html

public long getMax()
Returns the maximum amount of memory in bytes that can be used for memory management. This method returns -1 if the maximum memory size is undefined.

[3] https://docs.oracle.com/javase/8/docs/api/java/lang/management/ManagementFactory.html

static List getMemoryPoolMXBeans()
Returns a list of MemoryPoolMXBean objects in the Java virtual machine.

[4] https://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryPoolMXBean.html
MemoryUsage getUsage()
 

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.