Java GC Log Analyzer

Paste a JVM GC log for pause percentiles, throughput, allocation rate and a heap-over-time chart. Reads JDK 9+ unified and JDK 8 logs in your browser.

The interactive tool loads here when JavaScript runs.

About this tool

What is the Java GC Log Analyzer?

Paste or drop a JVM GC log and it becomes the four figures a tuning session starts from: pause percentiles (p50, p90, p99, max), throughput as the share of wall time not spent paused, an allocation-rate estimate from heap growth between collections, and a heap-over-time chart whose shape answers the leak question faster than any number. Warnings come first: frequent Full GCs, evacuation failures, Metaspace-forced collections and second-long pauses.

Two formats are read. JDK 9 and later write unified logging lines (-Xlog:gc*, the framework that replaced the old GC flags; Oracle's conversion table maps -XX:+PrintGCDetails to exactly -Xlog:gc*), and JDK 8 writes the classic [GC (cause) 61440K->10728K(235520K), 0.0133250 secs] shape, with or without the per-generation brackets and the [Metaspace: ...] block Full GC lines append. Anything else is refused by name rather than half-read.

Throughput is only printed when the log spans at least 5 seconds: pause-time over wall-time measured across a blink of a log is noise, and a figure that would mislead is left out. The log is parsed in this tab and never uploaded.

  • Pause percentiles (p50, p90, p99, max) and total paused time
  • Throughput shown only when the log spans 5 seconds or more
  • Heap-over-time sawtooth chart with the committed-heap line
  • Allocation-rate estimate from heap growth between collections
  • By-pause-type table with count, total and max, Full GCs highlighted
  • Warnings: frequent Full GCs, to-space exhausted, Metadata GC Threshold, promotion failure, allocation stalls, second-long p99
  • Reads JDK 9+ unified logs and JDK 8 PrintGC lines; runs entirely in your browser
Read the guide: How to Read HAR Files, GC Logs and SQLite Databases

Updated

How to use the Java GC Log Analyzer

  1. Turn on GC logging: JDK 9+ with java -Xlog:gc:file=gc.log (or -Xlog:gc* for detail), JDK 8 with -Xloggc:gc.log -XX:+PrintGCDetails. The overhead is negligible; production services should always run with it.
  2. Paste the log or drop the file. Press Analyze log, or Load a sample to see the output on a short G1 log first.
  3. Read the warnings first: each names the log line pattern it found and the usual cause.
  4. Check the heap chart: a sawtooth returning to the same floor is healthy; a climbing floor is a leak or a heap too small for the live set.
  5. Read the pause percentiles against your latency budget: p99 matters more than the average, because a request that lands in a 1.2-second pause experiences all of it.

Worked examples

A real G1 log, summarised

Input

The test-suite fixture: 5 seconds of an OpenJDK 17 G1 log with two System.gc() calls planted

Output

63 collections (2 full) over 5.0s · G1 · throughput 98.43%

Throughput 98.43% means the JVM was paused 1.57% of the time, inside G1's roughly-8%-GC-time design target. The two Full GCs would be alarming if the cause were heap pressure; the by-type table shows both are Pause Full (System.gc()), which is a code smell, not a sizing problem.

Percentiles, not averages

Input

The same fixture's 63 pauses

Output

pauses: p50 0.7 ms, p90 2.9 ms, p99 5.9 ms, max 5.9 ms · total 0.08s

The median pause is under a millisecond while the worst is eight times longer. Averages hide exactly this spread, which is why the tool reports percentiles; a pause-time goal is judged at p99, not at the mean.

Allocation rate from the log alone

Input

Heap growth between the fixture's collections, divided by the time between them

Output

allocation ≈ 6.6 GiB/s · reclaimed 747 MiB in all · peak heap 40.0 MiB

This fixture is an allocation stress test: it churns 6.6 GiB/s through a 48 MiB heap, which is why it collects every 80 milliseconds. On a real service this figure says whether tuning should target the collector or the code doing the allocating.

Too short to judge

Input

A pasted snippet with two collections 70 ms apart

Output

2 collections (0 full) over 0.1s, and no throughput figure

Pause share measured over 70 ms is noise, so the tool withholds throughput below a 5-second span instead of printing a confident wrong number. The percentiles still show, because individual pause durations are real regardless of span.

Background and insight

G1 has been the default collector since JDK 9, and Oracle's tuning guide describes its default aim as neither maximum throughput nor lowest latency but "relatively small, uniform pauses at high throughput". Its throughput dial is -XX:GCTimeRatio, default 12: the target share of time in GC is 1/(1+GCTimeRatio), about 8%. A log showing throughput far below 92% on a G1 service means the collector is working outside its own design target.

The pause types in the table mirror G1's phases: Pause Young (Normal) is the routine young collection, Concurrent Start begins marking, Remark and Cleanup are its short stop-the-world ends, and Prepare Mixed and Mixed collections reclaim old regions. Pause Full is the alarm: the guide calls it an in-place stop-the-world compaction of the whole heap that "might be very slow", and notes Full GCs are typically preceded by collections tagged (Evacuation Failure), G1 running out of space to copy survivors into. The guide's remedies, in order: a bigger heap, more concurrent marking threads (-XX:ConcGCThreads), an earlier marking start via the IHOP settings, and for Full GCs caused by System.gc(), -XX:+ExplicitGCInvokesConcurrent or -XX:+DisableExplicitGC.

The allocation rate here is estimated from the log itself: heap occupancy at the start of each collection minus occupancy after the previous one, divided by the time between them, averaged over positive samples. It is the demand side of GC tuning: a service allocating 6 GiB/s needs either that much young space per second or shorter intervals between pauses, and no pause-time goal can repeal that arithmetic.

Common use cases

  • Latency spikes with clean application metrics

    If p99 request latency jumps while CPU and code profiles look flat, the GC log is the first suspect: a p99 pause near your latency budget names the cause in one paste.

  • OutOfMemoryError triage before the heap dump

    The heap chart of the minutes before the crash shows whether memory climbed steadily (a leak) or spiked (one huge allocation), which decides whether the heap dump hunt starts at a collection class or a single array.

  • Right-sizing a container heap

    Peak heap, the post-collection floor and the allocation rate say what the live set and churn actually are, which beats guessing -Xmx from the previous incident.

  • Verifying a tuning change

    Compare the text summaries from before and after changing -Xmx or pause goals: percentiles, throughput and the Full GC count are the before-and-after numbers for the review.

  • Reading a log from a ticket

    Logs pasted into tickets arrive trimmed and mixed with application output; the parser reads the GC lines it recognises and ignores the rest, no log-file hygiene needed.

Tips and limitations

  • Always run production JVMs with GC logging on: -Xlog:gc:file=gc.log:time,uptime costs almost nothing and is the evidence every memory incident needs. Add filecount and filesize output options for rotation.
  • More than an occasional Full GC means the heap is too small for the live set or something calls System.gc(); the by-type table distinguishes the two by the cause in parentheses.
  • To-space exhausted lines mean an evacuation failed: Oracle's guide says G1 resumes normally after one, but repeated failures schedule a Full GC; raise the heap or -XX:G1ReservePercent before that happens.
  • Collections caused by Metadata GC Threshold are Metaspace-driven, not heap-driven: raise -XX:MetaspaceSize so class loading stops forcing collections.
  • Watch allocation rate across releases: a jump without a traffic jump means a new allocation hot spot, found with a profiler, not with GC flags.
  • ZGC logs parse too, but its pauses are sub-millisecond and logged separately from its concurrent cycles, so the pause table is not the interesting part there; read the Allocation Stall warnings instead.

Sources and further reading

  1. Garbage-First (G1) Garbage Collector, Oracle, HotSpot GC tuning guide. G1 phases, evacuation failure, humongous objects, IHOP
  2. Garbage-First Garbage Collector Tuning, Oracle, HotSpot GC tuning guide. GCTimeRatio=12 and the 8% target, Full GC causes and remedies
  3. The java Command, Oracle, JDK tool specifications. -Xlog syntax and the conversion table mapping PrintGCDetails to -Xlog:gc*

Frequently asked questions

How do I enable GC logging on my JVM?

JDK 9 and later: -Xlog:gc:file=gc.log, or -Xlog:gc* for full detail; Oracle's conversion table maps the old -XX:+PrintGCDetails to -Xlog:gc*. JDK 8: -Xloggc:gc.log -XX:+PrintGCDetails. Logging is cheap enough to leave on permanently in production.

What is a good GC throughput number?

G1's own default target is about 8% of time in GC (-XX:GCTimeRatio=12, target share 1/(1+ratio)), so above roughly 92% is within design and above 98% is comfortable. Judge it together with p99 pause: batch jobs trade pause for throughput, latency services the reverse.

How many Full GCs are too many?

In G1, Full GC is the fallback, not the routine: it compacts the whole heap in one stop-the-world pause. Occasional ones at deploy or from System.gc() are tolerable; recurring ones mean the live set no longer fits, and Oracle's remedies are a bigger heap, earlier concurrent marking, or stopping the System.gc() calls.

What does "To-space exhausted" mean in a G1 log?

An evacuation failure: G1 had nowhere to copy surviving objects, because the heap or its reserve was too small for the allocation spike. The tuning guide notes Full GCs are typically preceded by these, so treat the warning as the early version of the Full GC alarm.

Why does the tool sometimes show no throughput figure?

Throughput is paused time over wall time, and over a log spanning under 5 seconds that ratio is dominated by which instant the snippet happens to cover. The tool withholds the figure below that span rather than print one that would not survive a longer capture.

How is the allocation rate calculated from a GC log?

Heap occupancy at the start of collection n, minus occupancy after collection n-1, divided by the time between them, averaged over positive samples. It slightly underestimates during concurrent phases, but it needs no agent or profiler, only the log you already have.

Does this read ZGC, Shenandoah and CMS logs?

Unified-logging collection lines parse for all of them, including ZGC's percent-form heap figures, and the collector is named from the Using line. ZGC and Shenandoah pause times are logged outside the collection lines, so for those the heap trend and warnings are the useful parts. JDK 8 CMS lines of the classic [GC (cause) ...] shape parse; Full GC lines carrying a [Metaspace: ...] block do not yet, and the count says so honestly.

Is there an in-depth guide to the Java GC Log Analyzer?

Yes. “How to Read HAR Files, GC Logs and SQLite Databases” covers the background, how it works, common pitfalls and worked examples. Read the full guide.