-
- All Superinterfaces:
PlatformManagedObject
- All Known Subinterfaces:
MemoryPoolMXBean
public interface MemoryPoolMXBean extends PlatformManagedObject
The management and monitoring interface for a virtual machine memory pool. A memory pool is managed by one or more instances ofMemoryManagerMXBean.In any given Java virtual machine there can be at one or more instances of this interface. Each may be distinguished by their separate
ObjectNamevalue.Accessing this kind of
MXBeancan be done in one of three ways.- Invoking the static
ManagementFactory.getMemoryPoolMXBeans()method which returns aListof all currently instantiated MemoryPoolMXBeans. - Using a
MBeanServerConnection. - Obtaining a proxy MXBean from the static
ManagementFactory.newPlatformMXBeanProxy(javax.management.MBeanServerConnection, java.lang.String, java.lang.Class<T>)method, passing in the string "java.lang:type=MemoryPool,name= unique memory pool name " for the value of the second parameter.
- Since:
- 1.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MemoryUsagegetCollectionUsage()If supported by the virtual machine, returns aMemoryUsagewhich encapsulates this memory pool's memory usage after the most recent run of the garbage collector.longgetCollectionUsageThreshold()Returns this memory pool's collection usage threshold.longgetCollectionUsageThresholdCount()Returns the number of times that the memory usage for this memory pool has grown to exceed the collection usage threshold.String[]getMemoryManagerNames()Returns a string array containing the unique names of each memory manager that manages this memory pool.StringgetName()Returns the name of this memory pool.MemoryUsagegetPeakUsage()Returns information on the peak usage of the memory pool.MemoryTypegetType()Returns the memory pool's type.MemoryUsagegetUsage()Returns the current memory usage of this memory pool as estimated by the virtual machine.longgetUsageThreshold()Returns this memory pool's usage threshold.longgetUsageThresholdCount()Returns the number of times that the memory usage for this memory pool has grown to exceed the current usage threshold.booleanisCollectionUsageThresholdExceeded()Returns a boolean indication of whether or not this memory pool hit or exceeded the current value of the collection usage threshold after the latest garbage collection run.booleanisCollectionUsageThresholdSupported()Returns a boolean indication of whether or not this memory pool supports a collection usage threshold.booleanisUsageThresholdExceeded()Returns a boolean indication of whether or not this memory pool has hit or has exceeded the current value of the usage threshold.booleanisUsageThresholdSupported()Returns a boolean indication of whether or not this memory pool supports a usage threshold.booleanisValid()Returns a boolean indication of whether or not this memory pool may still be considered valid.voidresetPeakUsage()Updates this memory pool's memory usage peak value to be whatever the value of the current memory usage is.voidsetCollectionUsageThreshold(long threshold)Updates this memory pool to have a new value for its collection usage threshold.voidsetUsageThreshold(long threshold)Updates this memory pool to have a new value for its usage threshold.-
Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
-
-
-
-
Method Detail
-
getCollectionUsage
MemoryUsage getCollectionUsage()
If supported by the virtual machine, returns aMemoryUsagewhich encapsulates this memory pool's memory usage after the most recent run of the garbage collector. No garbage collection will be actually occur as a result of this method getting called.- Returns:
- a
MemoryUsageobject that may be interrogated by the caller to determine the details of the memory usage. Returnsnullif the virtual machine does not support this method.
-
getCollectionUsageThreshold
long getCollectionUsageThreshold()
Returns this memory pool's collection usage threshold.- Returns:
- the collection usage threshold in bytes. The default value as set by the virtual machine will be zero.
- Throws:
UnsupportedOperationException- if the memory pool does not support a collection usage threshold.- See Also:
isCollectionUsageThresholdSupported()
-
getCollectionUsageThresholdCount
long getCollectionUsageThresholdCount()
Returns the number of times that the memory usage for this memory pool has grown to exceed the collection usage threshold.- Returns:
- a count of the number of times that the collection usage threshold has been surpassed.
- Throws:
UnsupportedOperationException- if the memory pool does not support a collection usage threshold.- See Also:
isCollectionUsageThresholdSupported()
-
getMemoryManagerNames
String[] getMemoryManagerNames()
Returns a string array containing the unique names of each memory manager that manages this memory pool. A memory pool will always have at least one memory manager associated with it.- Returns:
- the names of all the memory managers for this memory pool.
-
getName
String getName()
Returns the name of this memory pool.- Returns:
- the name of this memory pool.
-
getPeakUsage
MemoryUsage getPeakUsage()
Returns information on the peak usage of the memory pool. The scope of this covers all elapsed time since either the start of the virtual machine or the peak usage was reset.- Returns:
- a
MemoryUsagewhich can be interrogated by the caller to determine details of the peak memory usage. Anullvalue will be returned if the memory pool no longer exists (and the pool is therefore considered to be invalid). - See Also:
resetPeakUsage(),isValid()
-
getType
MemoryType getType()
Returns the memory pool's type.- Returns:
- a
MemoryTypevalue indicating the type of the memory pool (heap or non-heap).
-
getUsage
MemoryUsage getUsage()
Returns the current memory usage of this memory pool as estimated by the virtual machine.- Returns:
- an instance of
MemoryUsagethat can be interrogated by the caller to determine details on the pool's current memory usage. Anullvalue will be returned if the memory pool no longer exists (in which case it is considered to be invalid). - See Also:
isValid()
-
getUsageThreshold
long getUsageThreshold()
Returns this memory pool's usage threshold.- Returns:
- the usage threshold in bytes. The default value as set by the virtual machine depends on the platform the virtual machine is running on. will be zero.
- Throws:
UnsupportedOperationException- if the memory pool does not support a usage threshold.- See Also:
isUsageThresholdSupported(),setUsageThreshold(long)
-
getUsageThresholdCount
long getUsageThresholdCount()
Returns the number of times that the memory usage for this memory pool has grown to exceed the current usage threshold.- Returns:
- a count of the number of times that the usage threshold has been surpassed.
- Throws:
UnsupportedOperationException- if the memory pool does not support a usage threshold.- See Also:
isUsageThresholdSupported()
-
isCollectionUsageThresholdExceeded
boolean isCollectionUsageThresholdExceeded()
Returns a boolean indication of whether or not this memory pool hit or exceeded the current value of the collection usage threshold after the latest garbage collection run.- Returns:
trueif the collection usage threshold was surpassed after the latest garbage collection run, otherwisefalse.- Throws:
UnsupportedOperationException- if the memory pool does not support a collection usage threshold.- See Also:
isCollectionUsageThresholdSupported()
-
isCollectionUsageThresholdSupported
boolean isCollectionUsageThresholdSupported()
Returns a boolean indication of whether or not this memory pool supports a collection usage threshold.- Returns:
trueif supported,falseotherwise.
-
isUsageThresholdExceeded
boolean isUsageThresholdExceeded()
Returns a boolean indication of whether or not this memory pool has hit or has exceeded the current value of the usage threshold.- Returns:
trueif the usage threshold has been surpassed, otherwisefalse.- Throws:
UnsupportedOperationException- if the memory pool does not support a usage threshold.- See Also:
isUsageThresholdSupported()
-
isUsageThresholdSupported
boolean isUsageThresholdSupported()
Returns a boolean indication of whether or not this memory pool supports a usage threshold.- Returns:
trueif supported,falseotherwise.
-
isValid
boolean isValid()
Returns a boolean indication of whether or not this memory pool may still be considered valid. A memory pool becomes invalid once it has been removed by the virtual machine.- Returns:
trueif the memory pool has not been removed by the virtual machine,falseotherwise.
-
resetPeakUsage
void resetPeakUsage()
Updates this memory pool's memory usage peak value to be whatever the value of the current memory usage is.- Throws:
SecurityException- if there is a security manager active and the method caller does not have ManagementPermission "control".- See Also:
ManagementPermission
-
setCollectionUsageThreshold
void setCollectionUsageThreshold(long threshold)
Updates this memory pool to have a new value for its collection usage threshold. Only values of zero or greater should be supplied. A zero value effectively turns off any further checking of collection memory usage by the virtual machine. A value greater than zero establishes the new threshold which the virtual machine will check against after each run of the garbage collector in the memory pool.- Parameters:
threshold- the size of the new collection usage threshold expressed in bytes.- Throws:
UnsupportedOperationException- if the memory pool does not support a collection usage threshold.IllegalArgumentException- if input valuethresholdis either negative or else is in excess of any maximum memory size that may have been defined for this memory pool.SecurityException- if there is a security manager active and the method caller does not haveManagementPermission"control".
-
setUsageThreshold
void setUsageThreshold(long threshold)
Updates this memory pool to have a new value for its usage threshold. Only values of zero or greater should be supplied. A zero value effectively turns off any further checking of memory usage by the virtual machine. A value greater than zero establishes the new threshold which the virtual machine will check against.- Parameters:
threshold- the size of the new usage threshold expressed in bytes.- Throws:
UnsupportedOperationException- if the memory pool does not support a usage threshold.IllegalArgumentException- if input valuethresholdis either negative or else is in excess of any maximum memory size that may have been defined for this memory pool.SecurityException- if there is a security manager active and the method caller does not haveManagementPermission"control".
-
-