

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Handling Cycles
incomplete
2: Pros and Cons
incomplete
3: Stack Frames
incomplete
4: Tracking Objects
incomplete
5: Free
incomplete
6: Frame References
incomplete
7: Mark and Sweep
incomplete
8: Mark
incomplete
9: Trace
incomplete
10: Sweep
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
We finally have enough machinery in place to start thinking about the "Mark and Sweep" part of our garbage collector.
Mark and Sweep garbage collection was first described by John McCarthy in 1960, primarily for managing memory in ((lisp)). It's a two-phase algorithm:
Note! We don't keep track of how many times a particular object is referenced, like we did with reference counting! Instead, we keep track of which objects are referenced in each stack frame and then traverse our container objects looking for any other referenced objects. That's what "traverse the object graph" means – a fancy way of saying "look for objects".