Glossary
What is mark-sweep garbage collection?
Mark-sweep is the oldest tracing garbage collector design: starting from the roots (the stack, globals and anything else the program can reach directly), mark every object you can reach, then walk all objects and free the ones left unmarked.
The tricolor abstraction
During marking every object is one of three colors. White: not reached yet (and freed at the end if it stays white). Gray: reached, but its own references not yet followed. Black: reached, and everything it points to is gray or black. Marking keeps a worklist of gray objects and blackens them one by one until none are left. clox keeps the gray objects on an explicit stack instead of recursing, so deep structures cannot overflow the C stack.
Where you build one
Twice on the path. Crafting Interpreters chapter 26 has you write one for clox, including the weak references needed for the interned string table and a rule for when to collect (when allocated bytes pass a threshold that grows with the heap). Then Knuth's §2.3.5, Lists and Garbage Collection covers marking in depth, including the Schorr-Waite trick of marking without any extra stack by temporarily reversing pointers.
Questions
Does mark-sweep move objects?
No. That is mark-compact or copying collection. Plain mark-sweep frees in place, so memory can fragment.
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.