Knowing your garbage collector
summary
Explains that CPython combines generational reference counting with cycles detector (objects carry refcount, three generations, thresholds) and walks the actual cycle-detection steps: refresh refcounts, subtract internal-generation references, find zero-count false positives, mark reachable, move survivors to older generation, free the rest. Notes PyPy uses an incremental MiniMark GC with nursery/arenas, minor and incremental major collections for many short-lived objects. Shows a small Python demo and uses the gc module API to force collections; the demo runs and reclaims cyclic garbage.
AI-written summary · about
chapters (23)
- 0:00Intro
- 0:24Agenda
- 1:24Motivation
- 2:23Memory Manual
- 4:41Garbage collection in every scenario
- 5:31History of garbage collection
- 6:20Definition of garbage collection
- 7:21Garbage collection tradeoffs
- 9:00Example
- 13:48Cycles
- 14:23Memory Leaks
- 15:25Garbage Collectors
- 16:37Cycle Detection
- 17:53Implementation
- 18:44Iterating
- 20:05Check reachable objects
- 20:50Move to next generation
- 27:18Some problems
- 28:05Incremental
- 29:13Pipe
- 30:54Memory Model
- 32:03Faces
- 33:00C Python
related talks
27mDemystifying Python’s Generational Garbage Collector
25mTime to Take Out the Trash: garbage collector
25mIs it me or Python memory management? 🤔💻
23mPython Memory Understanding
23mMemoirs of a Python Object: Memory Management and Improving Performance
29mZero Waste: Tricks to Recycle (Memory) Better
22mLow Level Python a Deep dive into the python sources
31mIntroducing Immortal Objects: Building Block Towards a Multi-core Python Runtime
