Uncontrolled heap retention in Go: how to tell a leak from a healthy cache
Description and use
godrain automatically compares retained heap growth in a Go service under steady load, classifies patterns, and points to call stacks holding memory, reducing manual analysis.
Problem
Determining whether growing heap memory in a Go service indicates a leak or intentional cache growth.
Outcome
godrain automates comparison of retained heap growth under steady load, classifies patterns, and points to call stacks responsible for memory retention, reducing manual analysis cycles.
Workflow
- Install godrain via go install
- Run the target service (e.g., leaky or cached demo)
- Execute godrain watch with appropriate URL, warmup, duration, and interval
- Review the output verdict and top stacks
- Adjust allowlist or load correlation if needed
- Repeat with realistic traffic and split surfaces if signal is messy
Evidence
After GC, does retained heap keep climbing without a ceiling — and which call stacks are holding it?
godrain watches a live net/http/pprof endpoint, samples heap with gc=1, aggregates retention by stack, then classifies growth.
Without an allowlist, a growing cache during warm-up looks guilty.
- Record date: 2026-10-10T23:41:40.198Z