#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::Crafting Interpreters::Ch 26 Garbage Collection
#columns:Front	Back	Tags
Crafting Interpreters ch 26, Garbage Collection: what does it cover?	A mark-sweep garbage collector: roots, marking with a gray stack (tricolor abstraction), tracing references, sweeping unreachable objects, weak references for the string table, and when to trigger collection.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::about
Crafting Interpreters ch 26, Garbage Collection: why does it matter?	GC is one of the most misunderstood parts of every runtime. After this, Java, Go and JavaScript GC logs make sense, and Knuth 2.3.5 will feel familiar.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::why
Crafting Interpreters ch 26, Garbage Collection: which part of the book is it in?	clox (bytecode VM, C)	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::part
Mark-sweep garbage collection: what is it?	Mark-sweep is a garbage collection algorithm that first marks every object reachable from a set of roots, then sweeps through all objects and frees the unmarked ones.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::definition
Mark-sweep garbage collection: Does mark-sweep move objects?	No. That is mark-compact or copying collection. Plain mark-sweep frees in place, so memory can fragment.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::definition
Mark-sweep garbage collection: What is a stress-test GC mode?	Collecting on every allocation. clox has a flag for it; it makes GC bugs show up immediately instead of rarely.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::definition
Crafting Interpreters ch 26, a common trap: “An object allocated but not yet reachable gets collected mid-operation.” What's the catch?	Push temporaries on the stack before allocating again.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::trap
Crafting Interpreters ch 26: what traps should you watch for?	<ul><li>Forgetting to mark compiler roots while compiling.</li><li>Not removing unmarked strings from the intern table before sweeping.</li></ul>	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::traps
Crafting Interpreters ch 26: which end-of-chapter challenges are worth your time?	Challenge 1 (shrink the object header) and challenge 2 (avoid clearing mark bits on every sweep) are good optimizations. Challenge 3 (try another GC algorithm) is a big project; save it for after the book.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::challenges
Crafting Interpreters ch 26, Garbage Collection: how should you work through it?	Enable the stress-GC mode (collect on every allocation) and the GC log as the book suggests. Most bugs only show up under stress mode.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::26 cracked.guide::kind::approach
