Caffeinated Coder
Book an appointment
Lesson 25 · How programs really run

Garbage collection

Every object a program makes takes memory, and that memory has to be given back. In C you do it by hand with free(), and mistakes cause leaks or use-after-free bugs. Step through eight lines of Python to watch CPython count references and free a list the moment its count hits zero, see how a reference cycle slips past the counts, and then watch a tracing collector mark what the roots can reach and sweep the rest.

11 min12 steps5 questionsBeginner
Fig 25 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.