Class GarbageCollectionNotificationInfo
java.lang.Object
com.sun.management.GarbageCollectionNotificationInfo
- All Implemented Interfaces:
CompositeDataView
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 perform the collection.
- The action performed by the garbage collector.
- The cause of the garbage collection action.
- A
GcInfoobject 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 save in 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:
- A garbage collection notification.
Used by every notification emitted by the garbage collector, the details about the notification are provided in the action String.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringNotification type denoting that the Java virtual machine has completed a garbage collection cycle. -
Constructor Summary
ConstructorsConstructorDescriptionGarbageCollectionNotificationInfo(String gcName, String gcAction, String gcCause, GcInfo gcInfo) Creates a newGarbageCollectionNotificationInfoinstance. -
Method Summary
Modifier and TypeMethodDescriptionfrom(CompositeData cd) Returns aGarbageCollectionNotificationInfoobject represented by the givenCompositeData.Return theCompositeDatarepresentation of thisGarbageCollectionNotificationInfo.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Field Details
-
GARBAGE_COLLECTION_NOTIFICATION
Notification type denoting that the Java virtual machine has completed a garbage collection cycle. This notification is emitted by a GarbageCollectorMXBean. The value of this notification type is "com.ibm.lang.management.gc.notification" which matches RI naming for compatibility.- See Also:
-
-
Constructor Details
-
GarbageCollectionNotificationInfo
public GarbageCollectionNotificationInfo(String gcName, String gcAction, String gcCause, GcInfo gcInfo) Creates a newGarbageCollectionNotificationInfoinstance.- Parameters:
gcName- the name of the garbage collector used to perform the collectiongcAction- the action of the performed by the garbage collectorgcCause- the cause the garbage collectiongcInfo- a GcInfo object providing statistics about the GC cycle
-
-
Method Details
-
getGcName
- Returns:
- the name of the garbage collector used to perform the collection.
-
getGcAction
- Returns:
- the action of the performed by the garbage collector
-
getGcCause
- Returns:
- the cause of the garbage collection
-
getGcInfo
- Returns:
- the GC information related to the last garbage collection
-
from
Returns aGarbageCollectionNotificationInfoobject represented by the givenCompositeData. The givenCompositeDatamust contain the following attributes:CompositeData attributes Attribute Name Type gcName java.lang.StringgcAction java.lang.StringgcCause java.lang.StringgcInfo com.ibm.lang.management.GcInfo- Parameters:
cd-CompositeDatarepresenting aGarbageCollectionNotificationInfo- Returns:
- a
GarbageCollectionNotificationInfoobject represented bycdifcdis notnull;nullotherwise - Throws:
IllegalArgumentException- ifcddoes not represent aGarbageCollectionNotificationInfoobject
-
toCompositeData
Return the
CompositeDatarepresentation of thisGarbageCollectionNotificationInfo.- Specified by:
toCompositeDatain interfaceCompositeDataView- Parameters:
ct- theCompositeTypethat the caller expects. This parameter is ignored and can be null.- Returns:
- the
CompositeDatarepresentation.
-