An insight into Go Garbage Collection
summary
Covers Go’s actual GC mechanics: escape analysis decides heap vs stack allocation, stacks grow and split, and allocators use per-P caches with 67 size classes; marking uses a tri‑color mark‑and‑sweep with a buffered write barrier (hybrid fast path plus overflow), about 25% of CPUs do background marking, and pacing follows GOGC default 100 to aim to double the heap before a cycle. Shows concrete tuning: pack structs, cut pointer counts, use sync.Pool to reuse objects, and warns raising GOGC reduces collection frequency but can cause big heap spikes.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:24Stack vs heap allocation
- 7:24Dynamic memory basics
- 10:17Garbage collection fundamentals
- 14:22Parallel garbage collection
- 20:31Write barriers in GC
- 25:20Marking phase details
- 30:52Memory pressure and tuning
- 40:34Tuning Go garbage collector
- 43:34Q&A
related talks
27mGarbage Collection Semantics
30mGo: escape analysis
54mGarbage Collection, State of the Art
30mMemory Management in Go: The good, the bad and the ugly
30mBalanced GC: A Copying Garbage Collector for Golang
48mGolang's Garbage
24mAdvancing Go Garbage Collection with Green Tea
19mHeap Optimization for Go Systems
