My Oracle Support Banner

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

Last updated on FEBRUARY 03, 2019

Applies to:

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


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

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


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.


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

MemoryUsage getUsage()


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

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

In this Document

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