Generational Collection and Remembered Sets
Trace a young heap without rescanning every older object and explain why recording old-to-young writes is necessary.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A partial collection has extra roots
Allocate new objects in a young region and collect it more often. A young object can remain live solely because a reachable old object references it. If scanning all old objects were required each time, much of the saved work would disappear. A remembered set or card table records old locations or coarse regions that may reference young data. Scanning those entries complements the ordinary roots.
A write barrier preserves the information across mutations
When an old object receives a pointer into the young region, update the bookkeeping required by the collector. Omitting that update could hide a live object on the next collection. Promotion can create similar obligations. Young survivors are often cheap to move when most recent objects die quickly, but survival and promotion patterns vary by workload. Copying collection explains how survivors move, and escape analysis can avoid heap allocation for some local objects.[1][2]