The HotSpot implementation of the java.lang.management.GarbageCollectorMXBean contains a propriatory extension which provides additionnal information about the last GC cycle. This information is provided in an instance of the com.sun.management.GcInfo class. However, the GarbageCollectorMXBean provides access only to the information of the last GC cycle. To get this information, users have to perform pooling on the GarbageCollectorMXBean but there's no guarantee that they will get the information for all GC cycles because several GC cycles might occur between two readings of the GarbageCollectorMXBean.
A solution to solve this issue is to send a JMX notification everytime a new GcInfo is available for the GarbageCollectorMXBean. To be able to send the notification, the HotSpot imlementation of the GarbageCollectorMXBean has to be extended to implement the javax.management.NotificationEmitter interface.
The format of the notification has already been discussed with the GC team, and a few additional fields
have been suggested. The proposed notification has the following fields:
- gcName (String) : same as the 'name' property in the GarbageCollectorMXBean's ObjectName
- gcAction (String) : a free String where the GC can specify which action it performed
- gcCause (String) : the event that triggered the GC action
- gcInfo (GcInfo) : the GcInfo object related to the GC Cycle that triggered the notification