JVM's garbage collection algorithm
Mark - sweep algorithm
Clear labeling algorithm is divided into two stages, marking phase and cleanup phase, the two phases is relatively inefficient, and will produce memory fragmentation after collection, not for the large object allocation memory space.
As shown below:
Replication algorithm
Replication algorithm solves the problem of memory fragmentation, but the attendant is the memory into two. The principle is: the memory into two, half of them each time, when the need to be recovered, say death to clean up the object, and then move to the other side of live objects, thus avoiding memory fragmentation.
Of course, in today's business virtual machine point of view, it does not need the memory into two, so the price is too big friends. 98% of the objects are born toward evening death, HotSpot memory into the new generation and the old era. Cenozoic is divided into Eden, from Suvivor, to Survivor and survivor Eden default size is 8: 1 is the new generation of recycling 90% of the entire new generation of memory.
Mark - Collation Algorithm
Tags to organize algorithm is surviving to the end of the moving object, and then clear the memory beyond the boundary. Mainly for old's collection.
Generational collection algorithm
Copy the new generation algorithm using a small amount of objects can be copied to a survivor of them. Year old mark finishing method used to collect.