Add a memory profile type
Developers investigating memory usage usually start with process RSS and then look at the heap profile. The live heap often covers less than half of a Go program's memory. It leaves out dead (unreachable but not yet swept) heap objects, goroutine and thread stacks, runtime metadata, and non-Go memory such as cgo allocations and mmap regions. Users today must reconcile RSS, runtime metrics, and the heap profile by hand.
The new memory profile type in runtime/pprof gives one consistent breakdown, taken at the most recent GC mark termination. A "Go Memory" frame splits into heap (live and dead, both with allocation stack traces), stacks (goroutines and OS threads), and runtime overhead (span and mcache metadata, GC metadata, profiling buckets, and other). Its total equals /memory/classes/total:bytes minus /memory/classes/heap/released:bytes.
pprof.Lookup("memory").WriteTo(f, 0)
When the OS reports RSS and RSS is at least Go Memory, the profile adds a "Non-Go Memory" frame equal to RSS minus Go Memory. Otherwise it omits that frame and adds a warning comment to the profile.
- Proposal
- #79179 by felixge
- Status
- Implemented on Nov 23, 2026
- Release
- Go 1.28
- Impact
- medium
- Area
- runtime/pprof