Skip to content

heaptrail user guide

Find what is holding your memory

heaptrail reads JVM and Android heap dumps from the command line. It ranks what takes the space, traces what keeps an object alive, and compares snapshots. Most modes stream the file instead of loading it, so a 224 MiB Android dump takes about a fifth of a second on a laptop. Output is plain text, with JSON for scripts and CI.

Start your first triage Install heaptrail

heaptrail
$ heaptrail -i heap.hprof --leak-suspects --exclude-soft-weak --top 1

Suspect 1 — 27.98MiB (26.2 % of heap)
  dominator: java.util.ArrayList (object_id=361762400)
  accumulating: 262517 instances of com.nexio.tv.domain.model.MetaPreview, total 26.04MiB
  path to GC root:

  Path from object_id=361762400 (depth 12 step(s)):
    start  ── id=361762400
    ...
    hop 3 ── id=361760584  (via com.nexio.tv.ui.screens.home.HomeViewModel.fullCatalogRows)
    ...
    hop 6 ── id=327606088  (via androidx.lifecycle.ViewModelStore.map)
    ...
    hop 9 ── id=327605632  (via androidx.navigation.NavControllerViewModel.viewModelStores)

A command-line tool

heaptrail has no window to click through. Each investigation is one command that prints a report you can read in a terminal, paste into a ticket, or parse with jq. For interactive graph browsing, use Eclipse MAT after heaptrail has narrowed the question.

What do you want to do?

New here?

  1. Install heaptrail with cargo install heaptrail or a prebuilt binary.
  2. Work through Your first triage, a real investigation from the first summary to the field that causes the leak.
  3. Keep Choose the right mode open: it maps the question you have to the command that answers it.

No heap dump of your own yet? Follow along with the files in the repository.

When to use heaptrail, and when not to

Reach for heaptrail when… Reach for Eclipse MAT or VisualVM when…
You want a first answer in seconds, from a terminal or a script. You want to click through references and pivot as you go.
The dump is large, or the machine is a CI runner or a remote box. You need OQL, or an HTML report for people who will not open a terminal.
An agent or a pipeline should read the result. You are doing an open-ended, exploratory session.

The two work well together. Use heaptrail to narrow the question, then open the dump in MAT if you need a graph session.

Use the search box (press S or /) to find a flag, an error message or a class name.

Get help and follow changes

Read what changed in each release in What's new, or on the GitHub releases page. If a step in this guide differs from your build, report it on GitHub with your heaptrail version (heaptrail --version), your operating system and the command you ran.