Cenozoic Recycling: (copy algorithm)
In the heap, the new generation mainly stores what is soon to be collected by GC or is not a particularly large object (whether the-xx:pretenuresizethreshold parameter is set). The new generation of the replication algorithm is divided into 3 regions: larger Eden and two smaller Survivor (the default eden:survivor = 8:1). Occurring in the Cenozoic GC is minor GC. When minor GC, the surviving objects in the Cenozoic are copied into a survivor, then the Eden and another survivor are cleaned up. Therefore, the usual available Cenozoic size is the size of Eden + a survivor size.
Old age Recycling: (Mark-Purge algorithm/tag-collation algorithm)
In the old age, there are objects (whether the-xx:pretenuresizethreshold parameters are set) that are still alive or particularly large in the program after several recoveries. In the old age, the mark-purge or tag-collation algorithm, which mainly looks at which collector the virtual machine uses, distinguishes between the two algorithms: Mark-purge can produce a lot of contiguous memory fragments. The GC in the old age is major GC. Major GC and full GC can cause stop-the-world.
Organize: Move all surviving objects, order in the Order of memory address, and reclaim all memory after the end memory address
The new generation enters the old age:
1. Distribution guarantee Mechanism: When the minor GC, the new generation of surviving objects than the survivor size, when a survivor can not fit them, then they will enter the old age.
2. If you set the-xx:pretenuresizethreshold3m then the object greater than 3M will go straight into the old age.
3. In the new generation of each minor GC will give in the new generation of objects + 1 years old, the default to 15 years old from the Cenozoic into the old age, you can set this point through-xx:maxtenuringthreshold.
In comparison, objects in the old age are less easily recycled than those in the Cenozoic.
Permanent generation Recycle: (i.e. method area Recycle)
The method area of the JVM, also known as the permanent generation. Here are some of the class information loaded by the virtual machine, static variables, constants, and other data. Things in this area are more difficult to recycle than the old and Cenozoic.
efficiency: Copy algorithm > tag/collation algorithm > tag/purge algorithm (efficiency here is simply a comparison of time complexity, which is not necessarily the case).
memory evenness: Replication algorithm = tag/collation algorithm > tag/purge algorithm.
Memory Utilization: tag/collation algorithm = tag/purge algorithm > Replication algorithm.