The young generation uses a fast copying garbage collector which employs two semi-spaces (survivor spaces) in the eden, copying surviving objects from one survivor space to the second.
The JVM allocates new objects in the eden space, and moves longer lived objects from the new generation to the old generation. The new generation includes the new object space (eden), and two survivor spaces. The heap space is divided into the old and the new generation. As these objects accumulate, a low memory condition occurs forcing GC to take place. The efficiency of a generational memory system is based on the observation that most of the objects are short lived. A generational memory system divides the heap into a few carefully sized partitions called generations. The process of locating and removing the dead objects can stall any application and consume as much as 25 percent throughput.Īlmost all Java Runtime Environments come with a generational object memory system and sophisticated GC algorithms. Garbage collection (GC) reclaims the heap space previously allocated to objects no longer needed. The following sections provide information on optimizing memory and allocation functions: The efficiency of any application depends on how well memory and garbage collection are managed.