Skip to content

Compare snapshots

One heap dump shows what is alive at one moment. It cannot say whether a number is growing, because it has no "before". These modes compare dumps of the same process: a pair for a clear before-and-after, or a series of three or more for a timeline.

Start here

Your goal, and the page

Your goal Command Page
What changed between two dumps? --diff-from a.hprof --diff-to b.hprof Snapshot diff
What keeps growing across a timeline? --diff-series a.hprof b.hprof c.hprof Diff a series
Is it Java heap growth or native? --native-context meminfo.txt Native context
Capture the dumps android-capture --series 3 Capture a series

Recipes

Your problem Recipe
Memory grows while media plays Playback growth
I want to know what one screen or action costs Before and after an interaction

What a comparison can and cannot tell you

  • It compares classes, not objects. Object ids are not stable between dumps, so heaptrail counts instances and shallow bytes per class name, and compares those totals.
  • It is shallow. A diff shows growth in the bytes objects occupy themselves. Use --retained-size on one dump to see what the growth keeps alive.
  • It needs the same build. Obfuscated names change between builds, so compare dumps of one build, or restore names with --mapping first.
  • A diff is a signal, not a proof. Growth between two dumps taken seconds apart may be warm-up. Capture around a deliberate, repeatable action, and prefer a series.