Java Zero to All All questionsPractise free
Interview questions › Interview Rapid-Fire — Top Q&A › JVM Internals — Top Interview Q&A

What is a Heap Dump and when would you analyze it?

Level IV · SeniorJVM Internals — Top Interview Q&A
Short answer

A heap dump is a snapshot of every object on the heap at a point in time — classes, fields, references, and retained sizes — typically written as an .hprof file.

Explanation

You analyze it to diagnose memory leaks and OutOfMemoryErrors: what is consuming memory and, via the dominator tree and reference chains, what is keeping it alive. Capture it with jmap -dump, jcmd GC.heap_dump, or automatically with -XX:+HeapDumpOnOutOfMemoryError, then open it in Eclipse MAT or VisualVM. It is a heavyweight, stop-the-world operation, so take it deliberately.

Common mistakes
  • Taking heap dumps on a live service without considering the pause.
  • Not knowing Eclipse MAT or dominator trees.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for JVM Internals — Top Interview Q&A.

Practise free

More on JVM Internals — Top Interview Q&A