Diagnosing Go memory leaks with pprof heap profiles
WHAT IT TESTS: production profiling with pprof. OUTLINE: expose net/http/pprof, grab /debug/pprof/heap, analyze inuse_space for live retention versus alloc_space for cumulative allocation; rising inuse over time points to a leak.
WHAT IT TESTS: practical heap profiling and the meaning of pprof sample types. ANSWER OUTLINE: register net/http/pprof, fetch the heap profile at /debug/pprof/heap, open it with go tool pprof. inuse_space and inuse_objects show memory still retained at sample time; alloc_space and alloc_objects show cumulative totals since start. A leak shows as inuse_space growing across successive snapshots; high alloc_space with flat inuse is just churn. RED FLAG: chasing alloc_space, which measures allocation rate, to find a leak.
Read the original → interview
- #go
- #pprof
- #profiling
- #memory-leak
- #observability
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.