CHAPTER 13 UNDERSTANDING OBJECT LIFETIME
The garbage collector will investigate all generation 0 objects first. If marking and sweeping (or said
more plainly, getting rid of) these objects results in the required amount of free memory, any surviving
objects are promoted to generation 1. To see how an object’s generation affects the collection process,
ponder Figure 13-5, which diagrams how a set of surviving generation 0 objects (A, B, and E) are
promoted once the required memory has been reclaimed.
Figure 13-5. Generation 0 objects that survive a garbage collection are promoted to generation 1
If all generation 0 objects have been evaluated, but additional memory is still required, generation 1
objects are then investigated for reachability and collected accordingly. Surviving generation 1 objects
are then promoted to generation 2. If the garbage collector still requires additional memory, generation
2 objects are evaluated. A