Java Heap Dump Analyzer

Drop an .hprof heap dump and see the class histogram, biggest objects and bytes wasted on duplicate arrays. Multi-GB dumps stream in your browser, unsent.

The interactive tool loads here when JavaScript runs.

About this tool

What is the Java Heap Dump Analyzer?

Drop the .hprof file that jcmd GC.heap_dump, jmap -dump or -XX:+HeapDumpOnOutOfMemoryError wrote, and this tool reads it into the summary a leak hunt starts from: total objects and bytes, the class histogram sorted by shallow bytes, the ten biggest single objects, and the bytes wasted in primitive arrays whose content is byte-for-byte identical.

The file is read in 8 MiB slices and fed through a streaming parser that keeps only running totals, never the object graph. That is what lets a dump larger than the browser's memory, a 4 GB .hprof from a production OutOfMemoryError included, summarise in one pass with a progress bar. Fed the same file whole or one byte at a time, the parser returns identical numbers, and the test suite pins that.

Nothing is uploaded. A heap dump contains every live string in the process, which can include credentials and personal data, so it is parsed by JavaScript in this tab and discarded when you close it.

  • Streams multi-GB .hprof files in 8 MiB slices with progress; no size limit beyond your disk
  • Class histogram by instance count and shallow bytes, with JVM names decoded
  • Ten biggest single objects and GC root count
  • Duplicate primitive array detection with exact wasted-byte figures
  • Identical results streamed or whole, pinned by tests
  • Copyable text summary, CSV and PDF report
  • Runs entirely in your browser; the dump is never uploaded
Read the guide: How to Capture and Read Heap Dumps and Thread Dumps

Updated

How to use the Java Heap Dump Analyzer

  1. Capture a dump: jcmd <pid> GC.heap_dump /tmp/app.hprof (add -all to include unreachable objects; the default requests a full GC and dumps live objects), or jmap -dump:live,format=b,file=app.hprof <pid>.
  2. If you used -gz, gunzip the file first; the tool reads plain HPROF and tells you when it sees a gzip header.
  3. Drop the file on the page. The progress bar shows the streamed bytes; a 1 GB dump takes a few seconds.
  4. Read the histogram: the top rows by shallow bytes are byte[], char[] and String in almost every dump, so the signal is usually in rows 2 to 10, where your own classes and collection internals (HashMap$Node, ConcurrentHashMap$Node) show their instance counts.
  5. Check the duplicate-array panel: a large "spent on repeat content" figure with few distinct shapes names an exact cache or buffer to deduplicate.

Worked examples

A dump built to the spec, read exactly

Input

A 1.2 KB HPROF fixture: two com.acme.Cache instances (16 data bytes each), four int[64] arrays, one GC root

Output

6 objects, 1.0 KiB shallow; top classes: int[] 4 × 1.0 KiB, com.acme.Cache 2 × 32 B

The fixture is assembled byte by byte from the format description in heapDumper.cpp, so every figure is known in advance; the test suite asserts the parser reproduces them all.

Duplicate arrays found by content

Input

Three of the fixture's four int[64] arrays carry identical values

Output

duplicate primitive arrays: 3 copies of an int[] of 64 elements, 512 B beyond the first

Each int[64] is 256 data bytes; keeping one and sharing it saves the other two, 512 B. The waste figure always counts copies beyond the first, which is what deduplication would recover.

Streaming gives the same answer as one buffer

Input

The same fixture pushed one byte at a time versus parsed whole

Output

Identical summaries, field for field

Records and even single array bodies cross slice boundaries in real dumps; the parser carries partial state across pushes. This equality is pinned in the test suite, which is what makes the 8 MiB slice size an implementation detail rather than a correctness risk.

JVM class names, printed the way people write them

Input

[B, [[I, [Ljava/lang/String;

Output

byte[], int[][], java.lang.String[]

HPROF stores JVM binary names. The histogram would be unreadable as [B and [Ljava/lang/String;, so names are decoded before aggregation.

Background and insight

The format is HPROF binary, "JAVA PROFILE 1.0.2", described in the comment at the top of heapDumper.cpp in the OpenJDK sources: a header naming the identifier size, then tagged records. UTF-8 strings (0x01) and class loads (0x02) give names; heap dump segments (0x1C) carry the objects as sub-records, instance dumps (0x21), object arrays (0x22) and primitive arrays (0x23), plus the GC roots. This parser resolves names from those records and aggregates per class.

Sizes here are the data bytes the dump records: an instance dump's "number of bytes that follow" field, which the format description says counts the field values of the class and its superclasses, and length times element size for arrays. The format carries no per-object header, so these shallow sizes run a little lower than a live jmap -histo, whose byte column includes the JVM's 12 to 16 byte header and alignment padding. Retained size, what an object keeps alive, needs the full reference graph and a dominator tree; this summary deliberately does not build one, and says so, because that is the job of Eclipse MAT once this histogram has told you which class to chase.

Duplicate detection hashes the content of every primitive array of 64 bytes or more (FNV-1a, two independent bases) and reports arrays with equal type, length and content. Identical byte[] and char[] at scale are the classic cheap win: the same JSON blob cached per user, a default buffer cloned per connection, or strings that would deduplicate under -XX:+UseStringDeduplication, which only covers the char arrays inside strings and only in young-enough regions.

Common use cases

  • OutOfMemoryError triage

    Run with -XX:+HeapDumpOnOutOfMemoryError, drop the resulting file, and read the top of the histogram: the class with millions of instances, or the one huge array in the biggest-objects table, is the suspect.

  • A heap that only grows

    Dump twice an hour apart and compare histograms: the class whose count rose and never fell is the leak. The text summary makes the two easy to diff.

  • Memory cost review before scaling

    Before paying for bigger instances, check the duplicate-array figure: caches that store the same bytes thousands of times are cheaper to fix than to host.

  • Dumps you cannot move

    A production dump often may not leave the machine it was copied to for compliance reasons. A browser tool with no upload is usable where a desktop install or an analysis service is not.

  • Deciding whether MAT is needed

    Most dumps do not need a dominator tree: the histogram and duplicates answer "what is big". Open MAT for the ones where you must know what is keeping a specific object alive.

Tips and limitations

  • Dump live objects (the default for jcmd, live for jmap) when hunting leaks: unreachable garbage inflates every number and a full GC removes it. Use -all only when you need the garbage itself, for example to see what churns.
  • Shallow bytes understate real footprint: the format carries no object headers, so 10 million small objects cost 120 to 160 MB more than the histogram shows. Counts matter as much as bytes.
  • byte[] and char[] at the top of the histogram are normal; they back strings, buffers and codecs. Look at who owns them (collection node counts, your own classes) before blaming arrays.
  • A dump written with -gz must be gunzipped first; the tool detects the gzip header and says so rather than failing on the magic check.
  • Every capture route, from jcmd and jmap to dump-on-OutOfMemoryError, JMX and Kubernetes, with pause times and file sizes measured on JDK 17, is in the guide to taking a Java heap dump (/blog/how-to-take-a-java-heap-dump).
  • The dump is a stop-the-world snapshot: jcmd pauses the JVM while writing, seconds to minutes for big heaps. On a sick production node, take the dump just before restarting it anyway.
  • For retained sizes, leak suspects by dominator, and path-to-GC-root questions, open the same file in Eclipse MAT or VisualVM; this page is the fast first pass, not a MAT replacement.

Sources and further reading

  1. heapDumper.cpp, HPROF binary format description, OpenJDK. The format comment: header, record tags, instance and array dump layouts, basic type codes
  2. The jcmd Command (JDK 21 tool specifications), Oracle. GC.heap_dump with its -all, -gz and -overwrite options
  3. The jmap Command (JDK 21 tool specifications), Oracle. jmap -dump:live,format=b,file=... and -histo[:live]

Frequently asked questions

Is it safe to analyze a heap dump in a browser?

Safer than most alternatives: a heap dump contains every live string in the process, including session tokens and personal data, and this page never transmits it. Parsing is local JavaScript; closing the tab discards everything. Treat the .hprof file itself as a secret regardless of the tool.

How is this different from Eclipse MAT?

MAT parses the full object graph, builds a dominator tree and answers retained-size and path-to-root questions; it needs an install, indexes and memory. This page streams the dump once and answers the first questions, what classes are big, what single objects are big, what is duplicated, in seconds. Start here; open MAT when you need ownership.

Why do the byte totals differ from jmap -histo on the live process?

Three reasons: the dump is a different moment; a live histogram includes objects a dump taken with the default live option collects first; and jmap -histo includes object headers while the HPROF format does not record them, so this tool's shallow bytes run lower, especially for small objects.

What is shallow size versus retained size in a heap dump?

Shallow is the object's own data: field bytes for instances, length times element size for arrays. Retained is everything that would become garbage if the object died, which requires the dominator tree over all references. This tool reports shallow only and labels it; a HashMap with a tiny shallow size can retain gigabytes.

How big a heap dump can the browser handle?

The dump is never loaded whole: 8 MiB slices stream through the parser and only per-class totals are kept, so multi-GB files work in ordinary tabs. The limit is time rather than memory, roughly a few seconds per gigabyte from a local disk.

How do I capture a heap dump in the first place?

jcmd <pid> GC.heap_dump /path/app.hprof is the supported command; jmap -dump:live,format=b,file=app.hprof <pid> is the older equivalent, and -XX:+HeapDumpOnOutOfMemoryError writes one automatically at the moment that matters most. All three produce the same HPROF binary format.

Why does the duplicate check only cover arrays of 64 bytes or more?

Hashing every tiny array costs time and finds noise: small arrays repeat naturally and deduplicating them rarely pays. 64 bytes is where identical content starts to mean a duplicated buffer or cached blob rather than coincidence.

Is there an in-depth guide to the Java Heap Dump Analyzer?

Yes. “How to Capture and Read Heap Dumps and Thread Dumps” covers the background, how it works, common pitfalls and worked examples. Read the full guide.