Uncontrolled heap retention in Go: how to tell a leak from a healthy cache
Описание и применение
godrain автоматически сравнивает рост удерживаемой памяти в Go‑приложении под стабильной нагрузкой, классифицирует паттерны и указывает стек вызовов, удерживающих память, снижая ручной анализ.
Задача
Determining whether growing heap memory in a Go service indicates a leak or intentional cache growth.
Результат
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.
Рабочий процесс
- 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
Доказательства
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.
- Дата записи: 2026-10-10T23:41:40.198Z