Summary
In this chapter, we zoomed in on the heap space. We started by examining the different generations on the heap – namely, the young generation space and the old generation (tenured) space.
The young generation space is divided into two spaces: the eden and survivor spaces. The eden space is where new objects are allocated. The survivor space consists of two equally sized spaces, namely S0 and S1. The minor (young generation) garbage collector uses these survivor spaces when reclaiming memory. Minor GC is triggered when there is not enough contiguous space to allocate an object in the eden space. Using pseudocode and diagrams, we examined how the minor garbage collector utilizes the generations and spaces. We then used an example that had several use case scenarios to reinforce the concepts.
The tenured space is where longer-lived objects reside. We saw that if an object survives several GC cycles, the object moves to tenured space to make subsequent minor GC cycles...