Go: escape analysis
summary
Explains how Go’s escape analysis decides stack vs heap placement, using go build with -gcflags "-m=1" and "-m=2" to show why returning a pointer, taking an address, interface conversions, or map/slice element pointers force heap allocation; shows stack starts at 2 KB and can grow up to 1 GB on 64-bit, and that large implicit variables (~65 KB) or unknown runtime sizes trigger heap moves. Notes GC is concurrent and can steal 25–50% CPU and that GOGC controls when collection runs.
AI-written summary · about
chapters (6)
- 0:00Introduction and agenda
- 1:53Memory layout in Go
- 5:55GC and scheduler basics
- 10:15Escape analysis explained
- 13:42Real-world code examples
- 28:04Summary and conclusion
related talks
22mUnderstanding Allocations: the Stack and the Heap
50mAn insight into Go Garbage Collection
26mGo Stack: Should It Be Moving Like That?
30mMemory Management in Go: The good, the bad and the ugly
38mUnderstanding Memory Allocation in Go
40mGolang memory footprint
50mUnderstanding the Go runtime
19mHeap Optimization for Go Systems
