Garbage collector

The garbage collector keeps track of which objects are still referenced (and thus, still needed) and removes all other objects, which are considered "garbage". Garbage collection only occurs when an allocation failure (AF) occurs due to lack of room in the heap, or possibly when a call to System.gc() occurs.

When an allocation failure occurs, the running thread that had the failure takes exclusive control of the VM. All application threads stop and garbage collection commences. This is referred to as a stop-the-world (STW) event.

The process of garbage collection consists of three phases:

Mark phase This is when all reachable objects are identified and all else is considered garbage.

Sweep phase This is when space used by all unmarked objects is reclaimed.

Compaction phase This is when objects are moved into as contiguous a space as possible and references are updated.

The compaction phase is the most costly because objects are moved and therefore require all references to them to be updated as well. Thus, compaction is always avoided if possible.

The four GC policies available to the IBM JVM each take different approaches to the handling of memory management and have been given descriptive names to help identify the purpose for each.

 

 

Additional references for the Java 5 garbage collector

For a more complete description of IBM Java memory management, including the heap and garbage collection, refer to Chapter 2 of IBM Java 5 Diagnostics Guide.

For additional information about the four GC policies available in the IBM JVM, refer to the following developerWorks article "Java Technology; IBM Style: Garbage collection policies, Part 1"

http://www-128.ibm.com/developerworks/java/library/j-ibmjava2/index.html

For further discussion about how to choose a GC policy, refer to the article "Java Technology; IBM Style; Garbage Collection policies, Part 2". This article focuses on Java applications in general and is not specific to WebSphere Application Server.

http://www-128.ibm.com/developerworks/java/library/j-ibmjava3/index.html