Memory Monitoring and Management Platform MBeans: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* http://docs.oracle.com/javase/8/docs/api/java/lang/management/BufferPoolMXBean.html
*
=Internal=
=Internal=


Line 14: Line 9:
{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryMXBean.html}}
{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryMXBean.html}}


Memory MBean implements the MemoryMXBean interface, and exists as a singleton instance in the JVM. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]], either programmatically by calling ManagementFactory.getMemoryMXBean() method, or by looking up the "java.lang:type=Memory" JMX ObjectName.
Memory MBean implements the MemoryMXBean interface, and exists as a singleton instance in the JVM. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]], either programmatically by calling ManagementFactory.getMemoryMXBean() method, or by looking up its ObjectName:
 
<pre>
java.lang:type=Memory
</pre>


Memory MBean exposes information about the [[Java_Memory_Concepts#Heap|heap]] and the [[Java_Memory_Concepts#Non-Heap_Memory|non-heap memory]], by returning snapshots in the form of [[#MemoryUsage_Instance|<tt>MemoryUsage</tt> instances]].
Memory MBean exposes information about the [[Java_Memory_Concepts#Heap|heap]] and the [[Java_Memory_Concepts#Non-Heap_Memory|non-heap memory]], by returning snapshots in the form of [[#MemoryUsage_Instance|MemoryUsage instances]].


The Memory MBean also exposes the "ObjectPendingFinalizationCount" JMX attribute, which is the approximate number for which finalization is pending.
Metrics:
* [[#HeapMemoryUsage|HeapMemoryUsage]]
* [[#NonHeapMemoryUsage| NonHeapMemoryUsage]]
* ObjectPendingFinalizationCount - the approximate number of objects pending finalization.


==MemoryUsage Instance==
==MemoryUsage Instance==
Line 58: Line 60:
==Eden Space==
==Eden Space==


The Eden Space memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]] by looking up the "java.lang:type=MemoryPool,name=PS Eden Space" JMX ObjectName. For more information about the Eden memory pool see:
The Eden Space memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]] by looking up its ObjectName:
 
<pre>
java.lang:type=MemoryPool,name=PS Eden Space
</pre>
 
Metrics:
 
* Usage
* CollectionUsage
* PeakUsage
 
For more information about the Eden memory pool see:


{{Internal|Java_Memory_Concepts#Eden|Eden}}
{{Internal|Java_Memory_Concepts#Eden|Eden}}
Line 64: Line 78:
==Survivor Space==
==Survivor Space==


The Survivor Space memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]] by looking up the "java.lang:type=MemoryPool,name=PS Survivor Space" JMX ObjectName. For more information about the Survivor Space memory pool see:
The Survivor Space memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]] by looking up its ObjectName:
 
<pre>
java.lang:type=MemoryPool,name=PS Survivor Space
</pre>
 
Metrics:
* Usage
* CollectionUsage
* PeakUsage
 
For more information about the Survivor Space memory pool see:


{{Internal|Java_Memory_Concepts#Survivor_Space|Survivor Space}}
{{Internal|Java_Memory_Concepts#Survivor_Space|Survivor Space}}
Line 70: Line 95:
==Old Generation==
==Old Generation==


The Old Generation memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]] by looking up the "java.lang:type=MemoryPool,name=PS Old Gen" JMX ObjectName. For more information about the Old Generation memory pool see:
The Old Generation memory pool MBean implements the MemoryPoolMXBean interface. The MBean instance is accessible from the [[JMX#The_Platform_MBean_Server|platform MBean server]] by looking up its ObjectName:
 
<pre>
java.lang:type=MemoryPool,name=PS Old Gen
</pre>
 
For more information about the Old Generation memory pool see:


{{Internal|Java_Memory_Concepts#Old_Generation|Old Generation}}
{{Internal|Java_Memory_Concepts#Old_Generation|Old Generation}}
Line 76: Line 107:
==Metaspace==
==Metaspace==


"java.lang:type=MemoryPool,name=Metaspace"
Object Name:
 
<pre>
java.lang:type=MemoryPool,name=Metaspace
</pre>
 
Metrics:
 
* Usage
* PeakUsage


==Code Cache==
==Code Cache==


"java.lang:type=MemoryPool,name=Code Cache"
ObjectName:
 
<pre>
java.lang:type=MemoryPool,name=Code Cache
</pre>
 
Metrics:
* Usage
* PeakUsage


==Compressed Class Space==
==Compressed Class Space==


"java.lang:type=MemoryPool,name=Compressed Class Space"
ObjectName:
 
<pre>
java.lang:type=MemoryPool,name=Compressed Class Space
</pre>
 
Metrics:
* Usage
* PeakUsage


=Memory Manager MBeans=
=Memory Manager MBeans=


{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryManagerMXBean.html}}
{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryManagerMXBean.html}}
* "java.lang:type=MemoryManager,name=CodeCacheManager"
* "java.lang:type=MemoryManager,name=Metaspace Manager"
* [[#Garbage_Collector_MBeans|Garbage collector MBeans]]


For more details about memory managers, see:
For more details about memory managers, see:
Line 94: Line 154:
{{Internal|Java_Memory_Concepts#Memory_Manager|Memory Managers}}
{{Internal|Java_Memory_Concepts#Memory_Manager|Memory Managers}}


=Garbage Collector MBean=
=Garbage Collector MBeans=


{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/GarbageCollectorMXBean.html}}
{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/GarbageCollectorMXBean.html}}
ObjectNames:
<pre>
java.lang:type=GarbageCollector,name=PS MarkSweep
java.lang:type=GarbageCollector,name=PS Scavenge
</pre>
Metrics:
* CollectionCount
* CollectionTime


For more details about garbage collectors, see:
For more details about garbage collectors, see:


{{Internal|Java_Memory_Concepts#Garbage_Collector|Garbage Collectors}}
{{Internal|Java_Memory_Concepts#Garbage_Collector|Garbage Collectors}}

Latest revision as of 14:25, 11 May 2017

Internal

Memory MBean

http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryMXBean.html

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:

MemoryUsage Instance

http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryUsage.html

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

http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryPoolMXBean.html

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:

Eden

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:

Survivor Space

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:

Old Generation

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

http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryManagerMXBean.html
  • "java.lang:type=MemoryManager,name=CodeCacheManager"
  • "java.lang:type=MemoryManager,name=Metaspace Manager"
  • Garbage collector MBeans

For more details about memory managers, see:

Memory Managers

Garbage Collector MBeans

http://docs.oracle.com/javase/8/docs/api/java/lang/management/GarbageCollectorMXBean.html

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:

Garbage Collectors