Copying Collection and Forwarding Pointers
Relocate live objects into a fresh space while preserving reference sharing and avoiding duplicate copies.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Forward each reachable object at most once
A copying collector begins with roots in an old allocation region. On encountering a reference to an uncopied object, allocate space in the new region, copy the object and record its new address in a forwarding entry. Subsequent references to the old object then use the same new address. If two roots referenced one original list node, both must refer to one new node, preserving alias identity.
Scan new objects until the copied region is complete
Keep an allocation frontier and a scan frontier in the new space. Scan each copied object’s reference fields, forwarding their targets as needed. When frontiers meet, every copied object’s outgoing links have been updated. The old region can then be reclaimed under the collector’s access model. Compaction improves contiguous placement but copying needs spare capacity and support for moving objects. Tracing reachability gives the liveness criterion. Generational collection often copies a much smaller young region.[1][2]