Quick revision
The short answer
With heaps of 100 GB or more, a full heap dump means a long pause, a file of around 100 GB and an analysis machine with even more memory, so it becomes the last resort, not the first tool. The strategy prefers lighter evidence first, such as class histograms, JFR old object samples and allocation profiling, and tracks heap after GC per memory pool and the sizes of caches from application metrics, so leaks are found long before an emergency. If a dump is truly needed, we take it from an instance removed from traffic, with storage and analysis capacity prepared in advance. We also consider splitting the data so each instance's heap stays smaller, and we practise the procedure before an incident needs it.
What to remember
In this answer, we saw that a full dump of a 100 GB heap costs a long pause, a file of similar size and an analysis machine with even more memory. So the strategy starts with lighter evidence such as class histograms, JFR old object samples and allocation profiling, tracks heap after GC and cache sizes continuously so leaks are found early, takes full dumps only from drained instances with storage and analysis prepared in advance, considers splitting data to keep heaps smaller, and practises the procedure before an incident.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
With heaps of 100 GB or more, a full heap dump means a long pause, a file of around 100 GB and an analysis machine with even more memory, so it becomes the last resort, not the first tool. The strategy prefers lighter evidence first, such as class histograms, JFR old object samples and allocation profiling, and tracks heap after GC per memory pool and the sizes of caches from application metrics, so leaks are found long before an emergency. If a dump is truly needed, we take it from an instance removed from traffic, with storage and analysis capacity prepared in advance. We also consider splitting the data so each instance's heap stays smaller, and we practise the procedure before an incident needs it.
Why this question is asked
Large heaps are increasingly common: in-memory caches, search indexes, analytics and data grids routinely run 100 GB or more, and ZGC makes such heaps practical for low-latency services. The diagnostic habits built for 2 GB services do not scale with them. A dump that takes five seconds on a small heap can stop a large one for many minutes, and the resulting file is hard to move or open. Interviewers ask this design question to see whether we can plan diagnostics ahead rather than improvise during an incident. In this answer, we will quantify the costs of a full dump, build a ladder of lighter evidence, add continuous monitoring, prepare the full dump procedure for when it is needed, and look at architecture and practice.
1What a Full Dump Costs at 100 GB
A heap dump is a stop-the-world operation. The JVM halts all application threads, by default runs a full GC to keep only live objects, and then walks the heap and writes every object. At a write speed of a few hundred megabytes per second, 80 GB of live data takes several minutes; with the full GC first and a slower disk, it can take much longer. For that time, the instance serves nothing, and in a cluster, other members may consider it dead and start rebalancing data.
The file is roughly the size of the live heap, so 80 GB or more, which needs free space on a fast volume and takes a long time to copy. Analysis is the third cost: tools like Eclipse MAT build indexes of the whole object graph and typically need memory in the same order as the heap or more, so analysing a 100 GB dump requires a machine with well over 100 GB of RAM and hours of parsing.
| Evidence | Pause | Output size | Contains data? |
|---|---|---|---|
| Application metrics | none | time series | no |
| JFR with old object samples | none noticeable | tens to hundreds of MB | class names and stacks |
| Class histogram | full GC, seconds or more | a few MB | no |
| Allocation profiling (JFR) | none noticeable | MB | stacks only |
| Full heap dump | minutes | about 100 GB | everything |
2Lighter Evidence First
Most memory questions can be answered without a full dump. A class histogram from jcmd GC.class_histogram lists instance counts and bytes per class; it triggers a full GC, so it pauses, but it writes no large file and contains no data. Two histograms an hour apart show which types grow. JFR's old object sample event records a sample of objects that have survived a long time, with the stack trace where each was allocated and, if enabled, the reference chain to a GC root. That is often enough to name the leaking code.
Allocation profiling, also from JFR, shows which code paths allocate the most, which helps when the problem is GC pressure rather than a leak. Together these give us the type, the allocation site and often the owner, at a cost that a large production instance can afford.
3Watching the Heap Continuously
The best large-heap incident is the one that never becomes an emergency. We export heap occupancy after GC per memory pool, for example old generation used after each collection with G1 or the live size after each cycle with ZGC, together with application-level numbers: entries and estimated bytes for every cache, queue lengths and session counts. Micrometer exposes JVM memory metrics, and caches like Caffeine expose their sizes.
With these metrics, a leak appears as a slow upward trend in heap after GC over days, and the cache metrics often point directly at the culprit, such as one cache growing by 2 GB per day. Alerts on the trend, for example heap after GC above 70 percent and rising for six hours, give the team days to investigate with light tools instead of minutes to react to an OOM.
4When a Full Dump Is Needed
Sometimes only the full object graph answers the question. Then we take the dump in a planned way. The instance is first removed from traffic and, for clustered systems, from the cluster membership or rebalancing, so the long pause does not trigger failovers. Health checks are relaxed so the orchestrator does not kill it mid-dump. Storage is prepared in advance: a fast volume with enough free space, provisioned as part of the runbook. Recent JDKs can write dumps with parallel threads and compression, which shortens the pause and shrinks the file at some CPU cost; check your version's options. The analysis machine, with enough memory and MAT configured with a large heap, is ready before we start, in the controlled environment where sensitive dumps belong.
- Light tools exhausted?YesPlan a full dumpNoUse histogram, JFR, metrics
- Drain the instancetraffic and cluster membership
- Relax health checksno restart mid-dump
- Dump to prepared fast storageparallel and compressed if supported
- Analyse on a large-memory machinecontrolled environment
- Return the instance to service
6 steps in order. Play them, or step through them one at a time.
5Architecture and Practice
A deeper option is to keep heaps from growing so large in the first place. Splitting data across more instances, for example sharding a cache by key into four 25 GB instances instead of one 100 GB instance, makes every diagnostic step cheaper, shortens restarts and reduces the blast radius of a failure. Moving rarely used data off-heap or to an external store can have the same effect. This is not always right, since large heaps have real benefits, but diagnosability should be one of the inputs to that decision.
Finally, we practise. A full dump of a 100 GB heap that nobody has ever tried will fail in an incident for a mundane reason: the volume was too small, the health check killed the pod, or the analysis machine had too little memory. A game day that runs the whole procedure on a production-sized test instance, and records the real pause time and file size, turns guesses into numbers and the runbook into something that works.
6Follow-up questions
Does ZGC make heap dumps faster?
No. ZGC keeps GC pauses short, but a heap dump still stops the application while it walks and writes the heap. The dump time depends on the amount of live data and disk speed, not on the collector's normal pauses.
Can we take a dump without stopping the service at all?
Not a consistent HotSpot heap dump. Some approaches fork the process or use operating system snapshots and analyse the copy, but they are complex and need careful testing. For most teams, draining one instance is the practical answer.
Why not just add more memory instead of diagnosing?
Because a leak grows into any amount of memory. More memory buys time, which is useful, but only finding the owner of the growth stops it. Metrics and light tools make that finding cheap.
7Conclusion
In this answer, we saw that a full dump of a 100 GB heap costs a long pause, a file of similar size and an analysis machine with even more memory. So the strategy starts with lighter evidence such as class histograms, JFR old object samples and allocation profiling, tracks heap after GC and cache sizes continuously so leaks are found early, takes full dumps only from drained instances with storage and analysis prepared in advance, considers splitting data to keep heaps smaller, and practises the procedure before an incident.
Open with
At a hundred gigabytes the full dump has to become the last resort. It's stop the world, minutes rather than seconds, usually with a full GC first, it produces a file of roughly the live heap size, and analysing it in MAT needs a machine with even more memory and hours of parsing.
Then, if they want more
In a cluster the long pause can also trigger failovers. So I'd plan a ladder. First, continuous monitoring: heap after GC per pool, plus application metrics for every cache, queue and session count, with trend alerts, so a leak shows up as days of slow growth rather than an OOM.
Second, light tools: class histograms an hour apart to see which types grow, and a continuous JFR recording with old object samples, which gives long-lived objects with their allocation stacks and, with path to GC roots, the reference chain, plus allocation profiling. Most leaks get solved there.
Third, if I really need the object graph, a planned dump: drain the instance from traffic and the cluster, relax health checks, write to fast storage provisioned in advance, use parallel or compressed dumping if the JDK supports it, and analyse on a prepared large-memory machine in a controlled environment, since it's sensitive data.
I'd also question the architecture, since sharding into several smaller heaps makes every diagnostic cheaper. And I'd run the whole procedure in a game day, so we know the real pause and file size before an incident.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Some services now run heaps of 100 GB or more. Taking and analysing a full heap dump...": https://scrivio-interview-library.netlify.app/java/jvm-diagnostics/c52844695c/