A specialized command-line tool for deep-diving into Go heap profiles (pprof).
This analyzer goes beyond standard pprof tools by applying heuristics to detect common memory anti-patterns, potential leaks, and high-pressure allocation hotspots.
This tool parses a standard pprof heap profile and generates a 7-section unified report:
time.After in loops, heavy JSON reflection, unoptimized slice growth).You can run the tool directly or build it as a binary.
make memcheck
memcheck <path-to-heap-profile.pb.gz>
Or run directly with go run:
go run main.go heap.pb.gz
Note: You must provide a standard Go heap profile (proto format). You can generate one from a running Go app using:
curl -o heap.pb.gz http://localhost:6060/debug/pprof/heap
Checks your profile against a list of known Go performance pitfalls:
time.After inside loops.regexp.Compile appearing in hot paths.json.Unmarshal.interface{}.growslice or mapassign (suggests missing capacity pre-allocation).Shows the exact source code location (File:Line) for the top allocators. This is often more useful than function names alone.
If your application uses pprof labels (e.g., pprof.Do), this section breaks down memory usage by those labels (e.g., per HTTP route or background worker ID).
Focuses on GC Pressure. Functions listed here churn through many small objects, causing the Garbage Collector to run frequently, even if total memory usage is low.
Focuses on RAM Usage. Lists functions that allocate memory that stays allocated.
For the top 5 allocators, this prints the stack trace up to the root. It attempts to tag the “Likely Cause” by skipping standard library functions to find your code.
A text-based tree view of memory consumption.
├── indicates a child call.