public interface MemoryPoolMXBean
Provides access to information about one of the memory
resources or pools used by the virtual machine. Instances
of this bean are obtained by calling
ManagementFactory.getMemoryPoolMXBeans()
. One
bean is returned for each memory pool provided.
The memory pool bean allows the usage of the pool to be monitored. The bean can provide statistics on the current and peak usage of the pool, and on the threshold levels the pool uses.
getUsage()
returns an approximation of the current
usage of the pool. Calls to this method are expected to be
generally quick to perform; if the call is expensive, the
documentation of the bean should specify so. For memory
pool beans that represent the memory used by garbage
collectors, the usage level includes both referenced and
unreferenced objects.
getPeakUsage()
and resetPeakUsage()
enable
the retrieval of the peak usage level and setting it to the
current usage level, respectively. Initially, the peak usage
level is relative to the start of the virtual machine.
Memory pools may also include optional support for usage thresholds. The usage threshold is a particular level of memory usage. When this value is crossed (the current memory usage becomes equal to or greater than this threshold level), the usage threshold count is increased. This feature is designed for monitoring the trend in memory usage. Support for a collection usage threshold is also provided, for particular garbage collectors. This is used to monitor the amount of memory left uncollected after a garbage collection cycle. There is no need to make special garbage collection runs to support this; the level following collection just needs to be monitored.
Modifier and Type | Method and Description |
---|---|
MemoryUsage |
getCollectionUsage()
Returns memory usage statistics after a best-effort attempt
has been made to remove unused objects from the pool.
|
long |
getCollectionUsageThreshold()
Returns the collection usage threshold level in bytes.
|
long |
getCollectionUsageThresholdCount()
Returns the number of times the usage level has matched or
exceeded the collection usage threshold.
|
String[] |
getMemoryManagerNames()
Returns the names of the memory managers associated with this
pool.
|
String |
getName()
Returns the name of the memory pool.
|
MemoryUsage |
getPeakUsage()
Returns memory usage statistics for the peak memory usage
of the pool.
|
MemoryType |
getType()
Returns the type of memory used by this pool.
|
MemoryUsage |
getUsage()
Returns memory usage statistics for the current memory usage
of the pool.
|
long |
getUsageThreshold()
Returns the usage threshold level in bytes.
|
long |
getUsageThresholdCount()
Returns the number of times the usage level has matched or
exceeded the usage threshold.
|
boolean |
isCollectionUsageThresholdExceeded()
Returns true if the collection usage level is equal to
or greater than the collection usage threshold.
|
boolean |
isCollectionUsageThresholdSupported()
Returns true if this memory pool supports a collection usage
level threshold.
|
boolean |
isUsageThresholdExceeded()
Returns true if the usage level is equal to
or greater than the usage threshold.
|
boolean |
isUsageThresholdSupported()
Returns true if this memory pool supports a usage level threshold.
|
boolean |
isValid()
Returns true if this memory pool is still valid.
|
void |
resetPeakUsage()
Resets the peak memory usage level to the current memory usage
level.
|
void |
setCollectionUsageThreshold(long threshold)
Sets the collection threshold usage level to the given value.
|
void |
setUsageThreshold(long threshold)
Sets the threshold usage level to the given value.
|
MemoryUsage getCollectionUsage()
null
if such functionality is
unsupported by the memory pool represented by this bean.null
if this operation is not supported.long getCollectionUsageThreshold()
UnsupportedOperationException
- if the collection usage
threshold is not supported.getCollectionUsageThresholdCount()
,
isCollectionUsageThresholdExceeded()
,
isCollectionUsageThresholdSupported()
,
setCollectionUsageThreshold(long)
long getCollectionUsageThresholdCount()
UnsupportedOperationException
- if the collection usage
threshold is not supported.getCollectionUsageThreshold()
,
isCollectionUsageThresholdExceeded()
,
isCollectionUsageThresholdSupported()
,
setCollectionUsageThreshold(long)
String[] getMemoryManagerNames()
MemoryUsage getPeakUsage()
resetPeakUsage()
. The return value
may be null
if this pool is no longer valid.null
if this pool is no longer valid.MemoryType getType()
MemoryUsage getUsage()
null
if
this pool is no longer valid. Obtaining these values is
expected to be a relatively quick operation; if this will
instead be an expensive operation to perform, the documentation
of the implementating bean should specify that this is the
case. The values are intended to be an estimate for monitoring
purposes.null
if this pool is no longer valid.long getUsageThreshold()
UnsupportedOperationException
- if the usage threshold
is not supported.getUsageThresholdCount()
,
isUsageThresholdExceeded()
,
isUsageThresholdSupported()
,
setUsageThreshold(long)
long getUsageThresholdCount()
UnsupportedOperationException
- if the usage threshold
is not supported.getUsageThreshold()
,
isUsageThresholdExceeded()
,
isUsageThresholdSupported()
,
setUsageThreshold(long)
boolean isCollectionUsageThresholdExceeded()
UnsupportedOperationException
- if the collection usage
threshold is not supported.getCollectionUsageThreshold()
,
getCollectionUsageThresholdCount()
,
isCollectionUsageThresholdSupported()
,
setCollectionUsageThreshold(long)
boolean isCollectionUsageThresholdSupported()
getCollectionUsageThreshold()
,
getCollectionUsageThresholdCount()
,
isCollectionUsageThresholdExceeded()
,
setCollectionUsageThreshold(long)
boolean isUsageThresholdExceeded()
UnsupportedOperationException
- if the usage threshold
is not supported.getUsageThreshold()
,
getUsageThresholdCount()
,
isUsageThresholdSupported()
,
setUsageThreshold(long)
boolean isUsageThresholdSupported()
getUsageThreshold()
,
getUsageThresholdCount()
,
isUsageThresholdExceeded()
,
setUsageThreshold(long)
boolean isValid()
void resetPeakUsage()
SecurityException
- if a security manager exists and
denies ManagementPermission("control").void setCollectionUsageThreshold(long threshold)
threshold
- the new threshold level.IllegalArgumentException
- if the threshold hold level
is negative.UnsupportedOperationException
- if the collection usage
threshold is not supported.SecurityException
- if a security manager exists and
denies ManagementPermission("control").getCollectionUsageThreshold()
,
getCollectionUsageThresholdCount()
,
isCollectionUsageThresholdExceeded()
,
isCollectionUsageThresholdSupported()
void setUsageThreshold(long threshold)
threshold
- the new threshold level.IllegalArgumentException
- if the threshold hold level
is negative.UnsupportedOperationException
- if the usage threshold
is not supported.SecurityException
- if a security manager exists and
denies ManagementPermission("control").getUsageThreshold()
,
getUsageThresholdCount()
,
isUsageThresholdExceeded()
,
isUsageThresholdSupported()