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:
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:
| Modifier and Type | Field and Description |
|---|---|
| private final CompositeData | |
| public static final String | GARBAGE_COLLECTION_NOTIFICATION
Notification type denoting that the Java virtual machine has completed a garbage collection cycle. |
| private final String | |
| private final String | |
| private final GcInfo | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public | GarbageCollectionNotificationInfo(String
The name of the garbage collector used to perform the collection gcName, String The name of the action performed by the garbage collector gcAction, String The cause of the garbage collection action gcCause, GcInfo a GcInfo object providing statistics about the GC cycle gcInfo)Constructs a |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public static GarbageCollectionNotificationInfo | Returns: aGarbageCollectionNotificationInfo object represented
by cd if cd is not null;
null otherwise.CompositeData representing a
GarbageCollectionNotificationInfoReturns a |
| public String | Returns: the action performed by the garbage collectorReturns the action performed by the garbage collector |
| public String | |
| public GcInfo | Returns: the GC information related to the last garbage collectionReturns the GC information related to the last garbage collection |
| public String | Returns: the name of the garbage collector used to perform the collectionReturns the name of the garbage collector used to perform the collection |
| public CompositeData | toCompositeData(CompositeType ct)
Implements javax. Return a |
| cdata | back to summary |
|---|---|
| private final CompositeData cdata | |
| GARBAGE_COLLECTION_NOTIFICATION | back to summary |
|---|---|
| public static final String GARBAGE_COLLECTION_NOTIFICATION Notification type denoting that
the Java virtual machine has completed a garbage collection cycle.
This notification is emitted by a | |
| gcAction | back to summary |
|---|---|
| private final String gcAction | |
| gcCause | back to summary |
|---|---|
| private final String gcCause | |
| gcInfo | back to summary |
|---|---|
| private final GcInfo gcInfo | |
| gcName | back to summary |
|---|---|
| private final String gcName | |
| GarbageCollectionNotificationInfo | back to summary |
|---|---|
| public GarbageCollectionNotificationInfo(String gcName, String gcAction, String gcCause, GcInfo gcInfo) Constructs a | |
| GarbageCollectionNotificationInfo | back to summary |
|---|---|
| pack-priv GarbageCollectionNotificationInfo(CompositeData cd) | |
| from | back to summary | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| public static GarbageCollectionNotificationInfo from(CompositeData cd) Returns a
| |||||||||||
| getGcAction | back to summary |
|---|---|
| public String getGcAction() Returns the action performed by the garbage collector
| |
| getGcCause | back to summary |
|---|---|
| public String getGcCause() Returns the cause of the garbage collection
| |
| getGcInfo | back to summary |
|---|---|
| public GcInfo getGcInfo() Returns the GC information related to the last garbage collection
| |
| getGcName | back to summary |
|---|---|
| public String getGcName() Returns the name of the garbage collector used to perform the collection
| |
| toCompositeData | back to summary |
|---|---|
| public CompositeData toCompositeData(CompositeType ct) Implements javax. Doc from javax. Return a | |