public class MemoryUsage
extends java.lang.Object
A memory pool usage snapshot with sizes and the time the snapshot was taken.
A MemoryUsage
object has the following fields to make tracking
memory pool sizes easier:
memoryPoolSizeType | The MemoryPoolSizeType of the memory pool. |
initialReserved | The amount of memory initially reserved for the memory pool when it was created. |
size | The amount of memory, both used and unused, currently in the memory pool. |
used | The amount of memory currently in use in the memory pool. |
elapsedTimeSinceJVMStartSec | The wall clock time at which the MemoryUsage object was created in units of elapsed seconds since the start of the JVM. |
Constructor and Description |
---|
MemoryUsage(MemoryPoolSizeType memoryPoolSizeType,
long initialReserved,
long size,
long used,
double elapsedTimeSinceJVMStartSec)
Constructs a new MemoryUsage instance using the enumerated type for the
size type.
|
Modifier and Type | Method and Description |
---|---|
static MemoryUsage |
from(javax.management.openmbean.CompositeData cd)
Constructs a
MemoryUsage object from the CompositeData passed. |
double |
getElapsedTimeSinceJVMStartSec()
Returns the wall clock time at which the
MemoryUsage object was
created in units of elapsed seconds since the start of the JVM. |
long |
getInitialReserved()
Returns the amount of memory initially reserved in bytes for the memory pool used
as the basis for creating this
MemoryUsage object. |
MemoryPoolSizeType |
getMemoryPoolSizeType()
Returns the
MemoryPoolSizeType for the memory pool used as the basis
for creating this MemoryUsage object. |
long |
getSize()
Returns the approximate amount of memory in bytes that the memory pool
currently occupies, both used and unused, when this
MemoryUsage object was created. |
long |
getUsed()
Returns the approximate amount of memory in bytes in use in the memory pool
when this
MemoryUsage object was created. |
java.lang.String |
toString()
Returns a String object with the information describing this
MemoryUsage object. |
public MemoryUsage(MemoryPoolSizeType memoryPoolSizeType, long initialReserved, long size, long used, double elapsedTimeSinceJVMStartSec)
Constructs a new MemoryUsage instance using the enumerated type for the size type.
memoryPoolSizeType
- The size type of the memory pool, whether it is a
fixed size or can expand or contract in size. See MemoryPoolSizeType
for valid values.initialReserved
- The amount of memory reserved for this memory
pool when the memory pool was originally created (bytes).size
- The sum of the current used plus the current unused memory for
this memory pool (bytes).used
- The amount of memory used (bytes).elapsedTimeSinceJVMStartSec
- The time when this MemoryUsage object was created with units
in seconds since the start of the JVM.java.lang.IllegalArgumentException
- if initialReserved
,
size
or used
is less than 0
or used
is greater than size
.public static MemoryUsage from(javax.management.openmbean.CompositeData cd)
Constructs a MemoryUsage
object from the CompositeData
passed.
The CompositeData input parameter must contain the following values:
Attribute Name Type MemoryPoolSizeType java.lang.String initialReserved java.lang.Long size java.lang.Long used java.lang.Long elapsedTimeSinceJVMStartSec java.lang.Double
cd
- The CompositeData
object from which to retrieve the required MemoryUsage
values.java.lang.IllegalArgumentException
- if cd
does not contain
MemoryUsage
data.public double getElapsedTimeSinceJVMStartSec()
Returns the wall clock time at which the MemoryUsage
object was
created in units of elapsed seconds since the start of the JVM.
MemoryUsage
object was created
in units of elapsed seconds since the start of the JVM.public long getInitialReserved()
Returns the amount of memory initially reserved in bytes for the memory pool used
as the basis for creating this MemoryUsage
object.
MemoryUsage
object.public MemoryPoolSizeType getMemoryPoolSizeType()
Returns the MemoryPoolSizeType
for the memory pool used as the basis
for creating this MemoryUsage
object.
MemoryPoolSizeType
for this MemoryUsage
object.public long getSize()
Returns the approximate amount of memory in bytes that the memory pool
currently occupies, both used and unused, when this
MemoryUsage
object was created.
The value returned by getUsed()
is expected to always be less
than or equal to the value returned by getSize
.
public long getUsed()
Returns the approximate amount of memory in bytes in use in the memory pool
when this MemoryUsage
object was created. The value returned
by getSize()
is expected to always be greater than or equal to
the value returned by getUsed
.
public java.lang.String toString()
MemoryUsage
object.toString
in class java.lang.Object
MemoryUsage
object. Submit a bug or feature request
Copyright © 2015-2017, Azul Systems, Inc. All rights reserved.
Azul Systems and Zing are registered trademarks of Azul Systems, Inc.