How Generational GC works ?
Totally what is Generational GC ?
thanks
How Generational GC works ?
Totally what is Generational GC ?
thanks
Wikipedia's explanation.
A generational GC (also known as ephemeral GC) divides objects into generations and, on most cycles, will place only the objects of a subset of generations into the initial white (condemned) set. Furthermore, the runtime system maintains knowledge of when references cross generations by observing the creation and overwriting of references. When the garbage collector runs, it may be able to use this knowledge to prove that some objects in the initial white set are unreachable without having to traverse the entire reference tree. If the generational hypothesis holds, this results in much faster collection cycles while still reclaiming most unreachable objects.
Basically, it's a heuristic approach. The Garbage collection puts newly created objects in a memory region (called white set), when this set is full, those objects that are still referenced are moved to another region, and the white set is cleared and populated with fresh new objects. The white set is the hypothesis that the objects found there are generally unreachable.
For further reading on JVM Fine-Tuning of Garbage Collection.
Simply, a generational collector manages memory in a series of areas of increasingly longer-lived objects. These areas are called generations. The youngest generation -- sometimes called the Eden generation -- consists of objects that have just been created. It tends to see a lot of change -- objects come and go from this generation all the time. The older generations have a lot less change. That's because the longer an object lasts, the more likely it is to continue to last.
A generational collector gains efficiency by partitioning memory this way, because it can spend most of its time looking in the small Eden generation, and it can ignore the oldest generations most of the time. By limiting the amount of memory that needs looking at, the collector reduced the amount of work it needs to do.