United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7036199 Adding a notification to the implementation of GarbageCollectorMXBeans
JDK-7036199 : Adding a notification to the implementation of GarbageCollectorMXBeans

Details
Type:
Enhancement
Submit Date:
2011-04-13
Status:
Closed
Updated Date:
2011-07-29
Project Name:
JDK
Resolved Date:
2011-07-18
Component:
core-svc
OS:
generic
Sub-Component:
java.lang.management
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Relates:

Sub Tasks

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

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.
                                     
2011-04-13
EVALUATION

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

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



Hardware and Software, Engineered to Work Together