Chapter 7, “Garbage Collection”

The Java garbage collector consists of a separate thread of execution that executes in the background and keeps track of all the objects that are used in a Java program. When an object is no longer reachable, it becomes subject to garbage collection.

A reachable object is an object that can be accessed directly or indirectly through the variables that are currently available to the program. An unreachable object is an object that is no longer reachable.

When an object becomes subject to garbage collection, it is not necessarily garbage collected immediately. It might, in fact, never be garbage collected. The program might terminate before the garbage collector gets around to reclaiming the object. Being subjected ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.