Interface GarbageCollectorMXBean

All Superinterfaces:
MemoryManagerMXBean, PlatformManagedObject
All Known Subinterfaces:
GarbageCollectorMXBean, GarbageCollectorMXBean

public interface GarbageCollectorMXBean extends MemoryManagerMXBean
The interface for managing and monitoring the virtual machine's garbage collection functionality.

Multiple instances of this interface are available to clients. Each may be distinguished by their separate ObjectName value.

Accessing this kind of MXBean can be done in one of three ways.

  1. Invoking the static ManagementFactory.getGarbageCollectorMXBeans() method which returns a List of all currently instantiated GarbageCollectorMXBeans.
  2. Using a MBeanServerConnection.
  3. Obtaining a proxy MXBean from the static ManagementFactory.newPlatformMXBeanProxy(javax.management.MBeanServerConnection, java.lang.String, java.lang.Class<T>) method, passing in the string "java.lang:type=GarbageCollector,name= unique collector's name " for the value of the second parameter.
Since:
1.5
  • Method Details

    • getCollectionCount

      long getCollectionCount()
      Returns in a long the number of garbage collections carried out by the associated collector.
      Returns:
      the total number of garbage collections that have been carried out by the associated garbage collector.
    • getCollectionTime

      long getCollectionTime()
      For the associated garbage collector, returns the total amount of time in milliseconds that it has spent carrying out garbage collection.
      Returns:
      the number of milliseconds that have been spent in performing garbage collection. This is a cumulative figure.