compare_heap_histos
Compare two Java heap histogram snapshots to identify memory growth patterns and detect potential leaks. Pinpoint classes with increasing instance counts between snapshots.
Instructions
Compare two jmap -histo snapshots taken at different times to detect memory growth patterns, leak candidates, and new allocations. Captures what is growing between snapshots.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | Yes | The SECOND (later) jmap -histo output. Capture after reproducing the suspected leak or after running under load. Allow at least 5-10 minutes between snapshots — short gaps may not accumulate enough growth to distinguish real leaks from normal allocation churn. Use the same `jmap -histo:live` flag as the before snapshot for a fair comparison. | |
| before | Yes | The FIRST (earlier) jmap -histo output. Capture from a stable baseline — before the suspected leak window or after application startup has settled. Use `jmap -histo:live <pid>` to force a GC before capturing, ensuring unreachable objects are excluded and the snapshot reflects true live objects. |