"매 stop-and-copy GC 의 BFS-style two-finger traversal". 1970년 C.J. Cheney 가 제시한 copying garbage collector 의 표준 algorithm — recursion 없이 queue-style 로 live object 를 from-space 에서 to-space 로 evacuate. 매 modern V8/SpiderMonkey young generation, OCaml minor heap, MLton 의 baseline.
매 핵심
매 semi-space 구조
Heap 을 두 개의 equal-sized region 으로 split: from-space, to-space.
voidScavenger::Process(){while(!worklist_.empty()){HeapObjectobj=worklist_.Pop();obj->IterateBody(this);// visits each pointer field
}}voidScavenger::VisitPointer(Object**slot){HeapObjectobj=HeapObject::cast(*slot);if(Heap::InFromSpace(obj)){HeapObjecttarget=EvacuateObject(obj);*slot=target;}}
Generational tweak
// Young gen uses Cheney; old gen uses mark-sweep.
// Promotion: if object survives N scavenges, copy to old-gen instead of to-space.
if(age(obj)>=PROMOTION_THRESHOLD)dst=old_gen_alloc(sz);elsedst=(char*)to_space+free_;
매 결정 기준
상황
Approach
Short-lived allocation 多
Cheney (semi-space) — fast bump alloc
Large heap, low live ratio
Cheney 우수 (cost ∝ live, not heap)
Mostly-live mature data
Mark-sweep / mark-compact
Real-time constraints
Incremental / concurrent GC (Shenandoah, ZGC)
Memory tight (mobile)
Mark-sweep (no 2× overhead)
기본값: Young generation 에 Cheney, old generation 에 mark-compact (generational hypothesis).