Memory Monitoring and Management Platform MBeans: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(73 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=Internal=
 
* [[JMX#Memory_Monitoring_and_Management|JMX]]
* [[Java_Memory#Monitoring|Java Memory]]
* [[Java_Memory_Concepts|Java Memory Concepts]]
 
=Memory MBean=
 
{{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 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|MemoryUsage instances]].
 
Metrics:
* [[#HeapMemoryUsage|HeapMemoryUsage]]
* [[#NonHeapMemoryUsage| NonHeapMemoryUsage]]
* ObjectPendingFinalizationCount - the approximate number of objects pending finalization.
 
==MemoryUsage Instance==
 
{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryUsage.html}}
 
<tt>MemoryUsage</tt> instances represent memory snapshots, and they are used by the JVM to represent both heap and non-heap [[Java_Memory_Concepts#Memory_Pool|memory pools]]. The memory pool snapshot is characterized by four values:
 
* <span id='MemoryUsage_init'></span>'''init''' - represents the initial amount in bytes the JVM requests from the O/S during startup, for this pool.
 
* <span id='MemoryUsage_used'></span>'''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.
 
* <span id='MemoryUsage_committed'></span>'''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, [[#MemoryUsage_committed|committed]] could be less than [[#MemoryUsage_init|init]].
 
* <span id='MemoryUsage_max'></span>'''max''' - represents the maximum amount of memory in bytes that can be used for memory management.
 
==HeapMemoryUsage==
 
Represents the [[#MemoryUsage_Instance|MemoryUsage]] snapshot for all heap's memory pools. The [[#MemoryUsage_used|used]] and [[#MemoryUsage_committed |committed]] size of the returned instance is the sum of the corresponding values for all heap memory pools. This is not the case for [[#MemoryUsage_init|init]] and [[#MemoryUsage_max|max]].
 
==NonHeapMemoryUsage==
 
Represents the [[#MemoryUsage_Instance|MemoryUsage]] snapshot for all non-heap memory pools. The [[#MemoryUsage_used|used]] and [[#MemoryUsage_committed |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 [[#MemoryUsage_init|init]] and [[#MemoryUsage_max|max]].
 
==Garbage Collection Initiation==
 
A Full GC can be initiated by invoking the <tt>gc()</tt> JMX operation. The <tt>gc()</tt> call is equivalent to calling:


* http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryMXBean.html
<pre>
* http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryManagerMXBean.html
System.gc()
* http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryPoolMXBean.html
</pre>
* http://docs.oracle.com/javase/8/docs/api/java/lang/management/BufferPoolMXBean.html
* http://docs.oracle.com/javase/8/docs/api/java/lang/management/GarbageCollectorMXBean.html


=Internal=
=Memory Pool MBeans=
 
{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryPoolMXBean.html}}
 
Expose statistics about [[Java_Memory_Concepts#Memory_Pool|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 [[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}}
 
==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 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}}
 
==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 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}}
 
==Metaspace==
 
Object Name:
 
<pre>
java.lang:type=MemoryPool,name=Metaspace
</pre>


* [[JMX#Memory_Monitoring_and_Management|JMX]]
Metrics:


* Usage
* PeakUsage


==Code Cache==


ObjectName:


<pre>
java.lang:type=MemoryPool,name=Code Cache
</pre>


Metrics:
* Usage
* PeakUsage


==Compressed Class Space==


ObjectName:


<pre>
java.lang:type=MemoryPool,name=Compressed Class Space
</pre>


Metrics:
* Usage
* PeakUsage


=Memory Manager MBeans=


{{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]]


=External=
For more details about memory managers, see:


* http://docs.oracle.com/javase/8/docs/api/java/lang/management/ThreadMXBean.html
{{Internal|Java_Memory_Concepts#Memory_Manager|Memory Managers}}


=Overview=
=Garbage Collector MBeans=


Represents the management interface for the thread system of the Java virtual machine. It is accessible under the "java.lang:type=Threading" JMX ObjectName.  
{{External|http://docs.oracle.com/javase/8/docs/api/java/lang/management/GarbageCollectorMXBean.html}}


=Metrics=
ObjectNames:


==ThreadCount==
<pre>
java.lang:type=GarbageCollector,name=PS MarkSweep
java.lang:type=GarbageCollector,name=PS Scavenge
</pre>


The current number of live threads including both daemon and non-daemon threads.
Metrics:


==DaemonThreadCount==
* CollectionCount
* CollectionTime


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


==TotalStartedThreadCount==
{{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