My Oracle Support Banner

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

Last updated on FEBRUARY 19, 2019

Applies to:

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

Goal

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

This document provides an explanation for the following questions:
1. Why does getMax() return the undefined value for G1 (see [2] below). The issue does not happen with CMS Garbage Collector.
2. Are there known defects in this area, if so, please provide the bugid(s)?
3. Are there other options or workarounds for getting the "max" for the above two memory pools?

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

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

[2] MemoryUsage API
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] ManagementFactory API
static List getMemoryPoolMXBeans()
Returns a list of MemoryPoolMXBean objects in the Java virtual machine.

[4] MemoryPoolMXBean API
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!


In this Document
Goal
Solution
References


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