Java / Java 17 Garbage Collection Interview Questions
What is a remembered set in G1 GC?
A remembered set (RSet) is a per-region data structure that tracks which other regions contain references pointing into that region.
Because G1 can collect a single region without scanning the whole heap, it needs a fast way to find all the inbound references to that region from elsewhere - the RSet provides exactly that, so a young or old region can be evacuated by consulting only the (much smaller) set of regions that actually reference it.
RSets are kept up to date incrementally: write barriers record cross-region pointer updates into per-thread buffers, and background refinement threads process those buffers to update the actual remembered sets, so the cost is amortized rather than paid all at once during a pause.
More Related questions...