G1 (garbage first) collector

Basic knowledge and principle analysis of G1 garbage collector - take a look

main feature

1. Divide into blocks according to the region, each block marked with S, E, O, H

2. Recycle according to cost performance, count the recovery space and time of each block separately, and sort according to cost performance

3. You can specify the user pause time and dynamically recycle the garbage size. Default 200ms

shortcoming

How to solve if there are cross-generational references?
For the region of the young generation, we will recycle every time, so there is no need to consider that the young generation points to the old generation.
How do we choose the references from the old generation to the young generation (if not, use the GC root scan of the entire heap), the idea proposed here is the memory set rset (remember set), G1 maintains an rset for each region,
memory Pointers to their own regions are centrally maintained, and the mark pointers are within the range of those card pages. Since G1 uses a lot of regions (each region has an rset), G1 uses relatively high memory, basically occupying 10% to 20% of Java's additional memory to maintain the work of the collector.

Guess you like

Origin blog.csdn.net/qq_29857681/article/details/125571888