java.lang.management

Class MemoryNotificationInfo

public class MemoryNotificationInfo extends Object

Represents the content of a notification emitted by the {@link MemoryMXBean}. Such notifications are emitted when one of the memory pools exceeds its usage or collection usage threshold. This object contains the following information, representing the state of the pool at the time of the notification:

Two types of notification are emitted by the {@link MemoryMXBean}: one for exceeding the usage threshold and one for exceeding the collection usage threshold. The value returned by {@link #getCount()} is dependent on this type; if the threshold exceeded is the usage threshold, then the usage threshold count is returned. If, instead, the collection usage threshold is exceeded, then the collection usage threshold count is returned.

This data is held in the user data part of the notification (returned by {@link javax.management.Notification#getUserData()}) encapsulated in a {@link javax.management.openmbean.CompositeData} object. The {@link #from(javax.management.openmbean.CompositeData)} method may be used to unwrap the value and obtain an instance of this class.

Since: 1.5

Field Summary
static StringMEMORY_COLLECTION_THRESHOLD_EXCEEDED
The type of notification emitted when the collection usage threshold is exceeded, following a garbage collection cycle.
static StringMEMORY_THRESHOLD_EXCEEDED
The type of notification emitted when the usage threshold is exceeded.
Constructor Summary
MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
Constructs a new {@link MemoryNotificationInfo} object using the specified pool name, usage level and threshold crossing count.
Method Summary
static MemoryNotificationInfofrom(CompositeData data)

Returns a {@link MemoryNotificationInfo} instance using the values given in the supplied {@link javax.management.openmbean.CompositeData} object.

longgetCount()
Returns the number of times the memory pool has crossed the usage threshold, as of the time of notification.
StringgetPoolName()
Returns the name of the pool which has crossed a threshold.
MemoryUsagegetUsage()
Returns the usage levels at the time of notification.

Field Detail

MEMORY_COLLECTION_THRESHOLD_EXCEEDED

public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED
The type of notification emitted when the collection usage threshold is exceeded, following a garbage collection cycle. The value is java.management.memory.collection.threshold.exceeded.

MEMORY_THRESHOLD_EXCEEDED

public static final String MEMORY_THRESHOLD_EXCEEDED
The type of notification emitted when the usage threshold is exceeded. After a notification is emitted, the usage level must drop below the threshold again before another notification is emitted. The value is java.management.memory.threshold.exceeded.

Constructor Detail

MemoryNotificationInfo

public MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
Constructs a new {@link MemoryNotificationInfo} object using the specified pool name, usage level and threshold crossing count.

Parameters: poolName the name of the pool which has exceeded a threshold. usage the usage level of the pool at the time of notification. count the number of times the threshold has been crossed.

Method Detail

from

public static MemoryNotificationInfo from(CompositeData data)

Returns a {@link MemoryNotificationInfo} instance using the values given in the supplied {@link javax.management.openmbean.CompositeData} object. The composite data instance should contain the following attributes with the specified types:

NameType
poolNamejava.lang.String
usagejavax.management.openmbean.CompositeData
countjava.lang.Long

The usage level is further described as:

NameType
initjava.lang.Long
usedjava.lang.Long
committedjava.lang.Long
maxjava.lang.Long

Parameters: data the composite data structure to take values from.

Returns: a new instance containing the values from the composite data structure, or null if the data structure was also null.

Throws: IllegalArgumentException if the composite data structure does not match the structure outlined above.

getCount

public long getCount()
Returns the number of times the memory pool has crossed the usage threshold, as of the time of notification. If this is the notification represented by the type {@link #MEMORY_THRESHOLD_EXCEEDED}, then the count is the usage threshold count. If this is the notification represented by the type {@link #MEMORY_COLLECTION_THRESHOLD_EXCEEDED}, then the count is the collection usage threshold count.

Returns: the number of times the appropriate threshold has been crossed.

getPoolName

public String getPoolName()
Returns the name of the pool which has crossed a threshold.

Returns: the name of the pool.

getUsage

public MemoryUsage getUsage()
Returns the usage levels at the time of notification.

Returns: the usage levels.