Save This Page
Home » openjdk-7 » java » lang » management » [javadoc | source]
java.lang.management
public class: MemoryUsage [javadoc | source]
java.lang.Object
   java.lang.management.MemoryUsage
A MemoryUsage object represents a snapshot of memory usage. Instances of the MemoryUsage class are usually constructed by methods that are used to obtain memory usage information about individual memory pool of the Java virtual machine or the heap or non-heap memory of the Java virtual machine as a whole.

A MemoryUsage object contains four values:

Below is a picture showing an example of a memory pool:

+----------------------------------------------+
+//////////////// | +
+//////////////// | +
+----------------------------------------------+

|--------|
init
|---------------|
used
|---------------------------|
committed
|----------------------------------------------|
max

MXBean Mapping

MemoryUsage is mapped to a CompositeData with attributes as specified in the from method.
Constructor:
 public MemoryUsage(long init,
    long used,
    long committed,
    long max) 
Method from java.lang.management.MemoryUsage Summary:
from,   getCommitted,   getInit,   getMax,   getUsed,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.lang.management.MemoryUsage Detail:
 public static MemoryUsage from(CompositeData cd) 
    Returns a MemoryUsage object represented by the given CompositeData. The given CompositeData must contain the following attributes:

    Attribute Name Type
    init java.lang.Long
    used java.lang.Long
    committed java.lang.Long
    max java.lang.Long
 public long getCommitted() 
    Returns the amount of memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use.
 public long getInit() 
    Returns the amount of memory in bytes that the Java virtual machine initially requests from the operating system for memory management. This method returns -1 if the initial memory size is undefined.
 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.

    This amount of memory is not guaranteed to be available for memory management if it is greater than the amount of committed memory. The Java virtual machine may fail to allocate memory even if the amount of used memory does not exceed this maximum size.

 public long getUsed() 
    Returns the amount of used memory in bytes.
 public String toString() 
    Returns a descriptive representation of this memory usage.