Class GarbageCollectionNotificationInfo

java.lang.Object
com.sun.management.GarbageCollectionNotificationInfo
All Implemented Interfaces:
CompositeDataView

public class GarbageCollectionNotificationInfo extends Object implements CompositeDataView
The information about a garbage collection

A garbage collection notification is emitted by GarbageCollectorMXBean when the Java virtual machine completes a garbage collection action The notification emitted will contain the garbage collection notification information about the status of the memory:

  • The name of the garbage collector used to perform the collection.
  • The action performed by the garbage collector.
  • The cause of the garbage collection action.
  • A GcInfo object containing some statistics about the GC cycle (start time, end time) and the memory usage before and after the GC cycle.

A CompositeData representing the GarbageCollectionNotificationInfo object is stored in the userdata of a notification. The from method is provided to convert from a CompositeData to a GarbageCollectionNotificationInfo object. For example:

      Notification notif;

      // receive the notification emitted by a GarbageCollectorMXBean and set to notif
      ...

      String notifType = notif.getType();
      if (notifType.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
          // retrieve the garbage collection notification information
          CompositeData cd = (CompositeData) notif.getUserData();
          GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd);
          ....
      }
 

The type of the notification emitted by a GarbageCollectorMXBean is:

Since:
1.7