com.bea.jvm
Interface GarbageCollector

All Superinterfaces:
Describable, JVMComponent

public interface GarbageCollector
extends JVMComponent

This interface represents a Garbage Collector in the JVM.

Author:
Calle Wilund
, Marcus Hirt

Method Summary
 void addFinalizationListener(FinalizationListener listener)
          Add listener to be notified whenever an Object has been finalized.
 void addFinalizationListener(FinalizationListener listener, boolean onlyFailed)
          Add listener to be notified whenever an Object has been finalized.
 void addGarbageCollectionListener(GarbageCollectionListener listener)
          Adds a listener to be notified whenever a Garbage Collection run has been performed.
 java.lang.String getDescription()
          A short description of the GC algorithm in use.
 long getLastGCEnd()
          Returns the time the last Garbage Collection run started.
 long getLastGCStart()
          Returns the time the last Garbage Collection run started.
 long getNurserySize()
          Returns the size of the nursery/youngspace in bytes.
 long getTotalGarbageCollectionCount()
          Returns the total number of collection runs performed so far.
 long getTotalGarbageCollectionTime()
          Returns the total time spent Garabage Collecting so far.
 boolean hasCompaction()
          Returns true if this Garbage Collector compacts the heap.
 boolean isConcurrent()
          Returns true if this Garbage Collector collects garbage concurrently, i.e. in a separate thread running concurrently with the other threads.
 boolean isGenerational()
          Returns true if this memory model uses a nursery/ young-space.
 boolean isIncremental()
          Returns true if this Garbage Collector collects garbage incrementally (in small steps, train algorithm or similar).
 boolean isParallel()
          Returns true if this Garbage Collector runs in parallel on several processors when collecting garbage.
 void removeFinalizationListener(FinalizationListener listener)
          Removes the specified listener.
 void removeGarbageCollectionListener(GarbageCollectionListener listener)
          Removes the specified GarbageCollectionListener.
 

Method Detail

getDescription

public java.lang.String getDescription()
A short description of the GC algorithm in use. For example 'Generational Concurrent', 'Parallel' etc.

Specified by:
getDescription in interface Describable
Returns:
a short description of the GC.
See Also:
Describable.getDescription()

isGenerational

public boolean isGenerational()
                       throws NotAvailableException
Returns true if this memory model uses a nursery/ young-space.

Returns:
true if this memory model has a nursery.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

hasCompaction

public boolean hasCompaction()
                      throws NotAvailableException
Returns true if this Garbage Collector compacts the heap.

Returns:
true if this memory model uses compaction.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

isIncremental

public boolean isIncremental()
                      throws NotAvailableException
Returns true if this Garbage Collector collects garbage incrementally (in small steps, train algorithm or similar).

Returns:
true if this GC is incremental.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

isConcurrent

public boolean isConcurrent()
                     throws NotAvailableException
Returns true if this Garbage Collector collects garbage concurrently, i.e. in a separate thread running concurrently with the other threads.

Returns:
true if this GC is concurrent.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

isParallel

public boolean isParallel()
                   throws NotAvailableException
Returns true if this Garbage Collector runs in parallel on several processors when collecting garbage.

Returns:
true if this GC is parallel.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getTotalGarbageCollectionCount

public long getTotalGarbageCollectionCount()
                                    throws NotAvailableException
Returns the total number of collection runs performed so far.

Returns:
the total number of GCs perfomed so far.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getLastGCStart

public long getLastGCStart()
                    throws NotAvailableException
Returns the time the last Garbage Collection run started.

Returns:
the time the last GC started.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getLastGCEnd

public long getLastGCEnd()
                  throws NotAvailableException
Returns the time the last Garbage Collection run started.

Returns:
the time the last GC ended.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getTotalGarbageCollectionTime

public long getTotalGarbageCollectionTime()
                                   throws NotAvailableException
Returns the total time spent Garabage Collecting so far.

Returns:
total time spent in GC, in ms, so far.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getNurserySize

public long getNurserySize()
                    throws NotAvailableException
Returns the size of the nursery/youngspace in bytes.

Returns:
the size of the nursery in bytes.
Throws:
NotAvailableException - if this functionality isn't available in this Garbage Collector or JVM.

addGarbageCollectionListener

public void addGarbageCollectionListener(GarbageCollectionListener listener)
                                  throws NotAvailableException
Adds a listener to be notified whenever a Garbage Collection run has been performed.

Parameters:
listener - the listener to use.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

removeGarbageCollectionListener

public void removeGarbageCollectionListener(GarbageCollectionListener listener)
                                     throws NotAvailableException
Removes the specified GarbageCollectionListener. It will no longer be notified about GC events.

Parameters:
listener - the listener to remove.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

addFinalizationListener

public void addFinalizationListener(FinalizationListener listener)
                             throws NotAvailableException
Add listener to be notified whenever an Object has been finalized.

Parameters:
listener - the listener to receive events whenever an object is finalized.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

addFinalizationListener

public void addFinalizationListener(FinalizationListener listener,
                                    boolean onlyFailed)
                             throws NotAvailableException
Add listener to be notified whenever an Object has been finalized.

Parameters:
listener - the listener to add.
onlyFailed - whether to only send events for finalizers that fail (i.e. throw an exception).
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

removeFinalizationListener

public void removeFinalizationListener(FinalizationListener listener)
                                throws NotAvailableException
Removes the specified listener.

Parameters:
listener - the listener to remove.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.