JDK-7036199 : Adding a notification to the implementation of GarbageCollectorMXBeans
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-04-13
  • Updated: 2017-05-16
  • Resolved: 2011-07-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b143Fixed
Related Reports
Relates :  
Description
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

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/hotspot/hotspot/rev/78542e2b5e35
13-05-2011

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/78542e2b5e35
12-05-2011

EVALUATION The information needed to generate the GcInfo instance are generated at the end of the GC cycle, when the GCMemoryManager::gc_end() method is executed. In order to prevent delays in the completion of the GC cycle, the notification is not sent immediately. If the current GCMemoryManager has listeners waiting for notifications, the GCStatInfo data are copied into a notification request which is then queued in a dedicated queue of pending requests. These requests are handled by the Service Thread which generates one notification per request, using the GCStatInfo to create the GcInfo instance. The javax.management.Notification instance used to encapsulate the notification has a timestamp field. The value used to fill the timestamp field is a timestamp recorded when the GCStatInfo data have been copied and stored in the notification request. So the timestamp reflects when the GC related information has been generated and not when the notification has been sent.
13-04-2011