Class MemoryNotificationInfo

java.lang.Object
java.lang.management.MemoryNotificationInfo

public class MemoryNotificationInfo extends Object
Encapsulates the details of a memory notification emitted by a MemoryMXBean when a memory pool exceeds a threshold value.

If the memory usage of a memory pool increases such that it reaches or exceeds the memory usage threshold, a MEMORY_THRESHOLD_EXCEEDED notification is sent.

If, upon the completion of a run of the garbage collector, a memory pool exceeds its collection usage threshold, a MEMORY_COLLECTION_THRESHOLD_EXCEEDED notification is sent.

Since:
1.5
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Notification type that signifies a memory pool's memory usage has grown to reach or exceed the collection usage threshold value set for it after a run of the garbage collector.
    static final String
    Notification type that signifies a memory pool has grown such that it now reaches or exceeds the usage threshold value set for it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
    Creates a new MemoryNotificationInfo instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Receives a CompositeData representing a MemoryNotificationInfo object and attempts to return the root MemoryNotificationInfo instance.
    long
    Returns the number of times that the memory usage has crossed the threshold relevant to the type of notification when the notification was constructed.
    Returns the name of the memory pool that the notification relates to.
    Returns an instance of MemoryUsage that encapsulates the memory usage of the memory pool that gave rise to this notification at the time the notification was created.

    Methods declared in class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MEMORY_THRESHOLD_EXCEEDED

      public static final String MEMORY_THRESHOLD_EXCEEDED
      Notification type that signifies a memory pool has grown such that it now reaches or exceeds the usage threshold value set for it.
      See Also:
    • MEMORY_COLLECTION_THRESHOLD_EXCEEDED

      public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED
      Notification type that signifies a memory pool's memory usage has grown to reach or exceed the collection usage threshold value set for it after a run of the garbage collector.
      See Also:
  • Constructor Details

    • MemoryNotificationInfo

      public MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
      Creates a new MemoryNotificationInfo instance.
      Parameters:
      poolName - the name of the memory pool that the notification relates to.
      usage - the memory usage for the named pool
      count - the number of times that the memory usage of the memory pool has met or exceeded the relevant threshold. For notifications of the MEMORY_THRESHOLD_EXCEEDED type, this will a count of the number of times the memory usage threshold has been met or exceeded. For MEMORY_COLLECTION_THRESHOLD_EXCEEDED notifications, this will be the number of times that the collection usage threshold was passed.
      Throws:
      NullPointerException - when poolName or usage is null
  • Method Details

    • getCount

      public long getCount()
      Returns the number of times that the memory usage has crossed the threshold relevant to the type of notification when the notification was constructed. For notifications of the MEMORY_THRESHOLD_EXCEEDED type, this will a count of the number of times the memory usage threshold has been met or exceeded. For MEMORY_COLLECTION_THRESHOLD_EXCEEDED notifications, this will be the number of times that the collection usage threshold was passed.
      Returns:
      the number of times the related memory usage was passed at the time of the notification construction.
    • getPoolName

      public String getPoolName()
      Returns the name of the memory pool that the notification relates to.
      Returns:
      the name of the associated memory pool.
    • getUsage

      public MemoryUsage getUsage()
      Returns an instance of MemoryUsage that encapsulates the memory usage of the memory pool that gave rise to this notification at the time the notification was created. The MemoryUsage may be interrogated by the caller to find out the details of the memory usage.
      Returns:
      the memory usage of the related memory pool at the point when this notification was created.
    • from

      public static MemoryNotificationInfo from(CompositeData cd)
      Receives a CompositeData representing a MemoryNotificationInfo object and attempts to return the root MemoryNotificationInfo instance.
      Parameters:
      cd - a CompositeDate that represents a MemoryNotificationInfo.
      Returns:
      if cd is non- null, returns a new instance of MemoryNotificationInfo. If cd is null, returns null.
      Throws:
      IllegalArgumentException - if argument cd does not correspond to a MemoryNotificationInfo with the following attributes:
      • poolName(java.lang.String)
      • usage( javax.management.openmbean.CompositeData)
      • count( java.lang.Long)

      The usage attribute must represent a MemoryUsage instance which encapsulates the memory usage of a memory pool.