- java.lang.Object
-
- java.lang.management.MemoryUsage
-
public class MemoryUsage extends Object
Represents the memory usage of either a memory pool or the heap and non-heap memory areas of the virtual machine.- Since:
- 1.5
-
-
Constructor Summary
Constructors Constructor Description MemoryUsage(long init, long used, long committed, long max)Constructs a newMemoryUsageinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MemoryUsagefrom(CompositeData cd)Receives aCompositeDatarepresenting aMemoryUsageobject and attempts to return the rootMemoryUsageinstance.longgetCommitted()Returns the amount of memory that has been pledged by the operating system for the virtual machine to use.longgetInit()Returns the initial amount of memory requested from the underlying operating system when the virtual machine started up.longgetMax()Returns the maximum amount of memory that is available to the virtual machine which may change over the lifecycle of the virtual machine.longgetUsed()Returns the number of bytes currently used for memory management purposes.StringtoString()Returns a text description of this memory usage.
-
-
-
Constructor Detail
-
MemoryUsage
public MemoryUsage(long init, long used, long committed, long max)Constructs a newMemoryUsageinstance.- Parameters:
init- if defined, the initial amount of memory that can be allocated by the virtual machine in bytes. If not defined, then-1.used- the number of bytes currently used for memory.committed- the number of bytes of committed memory.max- if defined, the maximum number of bytes that can be used for memory management purposes. If not defined,-1.- Throws:
IllegalArgumentException- if any of the following conditions applies:init<-1max<-1used<0committed<0used>committedcommitted>maxifmaxis not-1.
-
-
Method Detail
-
getCommitted
public long getCommitted()
Returns the amount of memory that has been pledged by the operating system for the virtual machine to use. This value is in bytes.- Returns:
- the number of bytes committed to memory.
-
getInit
public long getInit()
Returns the initial amount of memory requested from the underlying operating system when the virtual machine started up. The value is given in bytes.if the initial memory size was not defined, this method will return a value of
-1.- Returns:
- the initial amount of memory requested at virtual machine start
up.
-1if not defined.
-
getMax
public long getMax()
Returns the maximum amount of memory that is available to the virtual machine which may change over the lifecycle of the virtual machine. The value is in bytes.- Returns:
- if defined, the maximum memory size in bytes. If not defined,
-1.
-
getUsed
public long getUsed()
Returns the number of bytes currently used for memory management purposes.- Returns:
- the current number of bytes used for memory.
-
toString
public String toString()
Returns a text description of this memory usage.
-
from
public static MemoryUsage from(CompositeData cd)
Receives aCompositeDatarepresenting aMemoryUsageobject and attempts to return the rootMemoryUsageinstance.- Parameters:
cd- aCompositeDatethat represents aMemoryUsage.- Returns:
- if
cdis non-null, returns a new instance ofMemoryUsage. Ifcdisnull, returnsnull. - Throws:
IllegalArgumentException- if argumentcddoes not correspond to aMemoryUsagewith the following attributes all of typejava.long.Long:committedinitmaxused
-
-