java.lang.Object
java.lang.management.MemoryUsage
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
ConstructorsConstructorDescriptionMemoryUsage
(long init, long used, long committed, long max) Constructs a newMemoryUsage
instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryUsage
from
(CompositeData cd) Receives aCompositeData
representing aMemoryUsage
object and attempts to return the rootMemoryUsage
instance.long
Returns the amount of memory that has been pledged by the operating system for the virtual machine to use.long
getInit()
Returns the initial amount of memory requested from the underlying operating system when the virtual machine started up.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.long
getUsed()
Returns the number of bytes currently used for memory management purposes.toString()
Returns a text description of this memory usage.
-
Constructor Details
-
MemoryUsage
public MemoryUsage(long init, long used, long committed, long max) Constructs a newMemoryUsage
instance.- 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
<-1
max
<-1
used
<0
committed
<0
used
>committed
committed
>max
ifmax
is not-1
.
-
-
Method Details
-
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.
-1
if 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
Returns a text description of this memory usage. -
from
Receives aCompositeData
representing aMemoryUsage
object and attempts to return the rootMemoryUsage
instance.- Parameters:
cd
- aCompositeDate
that represents aMemoryUsage
.- Returns:
- if
cd
is non-null
, returns a new instance ofMemoryUsage
. Ifcd
isnull
, returnsnull
. - Throws:
IllegalArgumentException
- if argumentcd
does not correspond to aMemoryUsage
with the following attributes all of typejava.long.Long
:committed
init
max
used
-