Memory Monitoring and Management Platform MBeans
Internal
Memory MBean
Memory MBean implements the MemoryMXBean interface, and exists as a singleton instance in the JVM. The MBean instance is accessible from the platform MBean server, either programmatically by calling ManagementFactory.getMemoryMXBean() method, or by looking up its ObjectName:
java.lang:type=Memory
Memory MBean exposes information about the heap and the non-heap memory, by returning snapshots in the form of MemoryUsage instances.
Metrics:
- HeapMemoryUsage
- NonHeapMemoryUsage
- ObjectPendingFinalizationCount - the approximate number of objects pending finalization.
MemoryUsage Instance
MemoryUsage instances represent memory snapshots, and they are used by the JVM to represent both heap and non-heap memory pools. The memory pool snapshot is characterized by four values:
- init - represents the initial amount in bytes the JVM requests from the O/S during startup, for this pool.
- used - represents the amount of used memory, for this pool, in bytes. The value includes the live memory objects and garbage objects that have not been collected yet.
- committed - represents the amount of memory in bytes that is guaranteed to be available for use by the JVM for this pool. The amount of committed memory may increase or decrease over time, as the JVM may release memory to the system. Over time, committed could be less than init.
- max - represents the maximum amount of memory in bytes that can be used for memory management.
HeapMemoryUsage
Represents the MemoryUsage snapshot for all heap's memory pools. The used and committed size of the returned instance is the sum of the corresponding values for all heap memory pools. This is not the case for init and max.
NonHeapMemoryUsage
Represents the MemoryUsage snapshot for all non-heap memory pools. The used and committed size of the returned instance is the sum of the corresponding values for all non-heap memory pools. This is not the case for init and max.
Garbage Collection Initiation
A Full GC can be initiated by invoking the gc() JMX operation. The gc() call is equivalent to calling:
System.gc()
Memory Pool MBeans
Expose statistics about memory pools. All memory pool MBeans described below can be obtained programmatically by calling ManagementFactory.getMemoryPoolMXBeans() method, or by looking up their specific ObjectName.
Eden Space
The Eden Space memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the platform MBean server by looking up its ObjectName:
java.lang:type=MemoryPool,name=PS Eden Space
Metrics:
- Usage
- CollectionUsage
- PeakUsage
For more information about the Eden memory pool see:
Survivor Space
The Survivor Space memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the platform MBean server by looking up its ObjectName:
java.lang:type=MemoryPool,name=PS Survivor Space
Metrics:
- Usage
- CollectionUsage
- PeakUsage
For more information about the Survivor Space memory pool see:
Old Generation
The Old Generation memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the platform MBean server by looking up its ObjectName:
java.lang:type=MemoryPool,name=PS Old Gen
For more information about the Old Generation memory pool see:
Metaspace
Object Name:
java.lang:type=MemoryPool,name=Metaspace
Metrics:
- Usage
- PeakUsage
Code Cache
ObjectName:
java.lang:type=MemoryPool,name=Code Cache
Metrics:
- Usage
- PeakUsage
Compressed Class Space
ObjectName:
java.lang:type=MemoryPool,name=Compressed Class Space
Metrics:
- Usage
- PeakUsage
Memory Manager MBeans
- "java.lang:type=MemoryManager,name=CodeCacheManager"
- "java.lang:type=MemoryManager,name=Metaspace Manager"
- Garbage collector MBeans
For more details about memory managers, see:
Garbage Collector MBeans
ObjectNames:
java.lang:type=GarbageCollector,name=PS MarkSweep java.lang:type=GarbageCollector,name=PS Scavenge
Metrics:
- CollectionCount
- CollectionTime
For more details about garbage collectors, see: