Converter tool

Java GC Log Analyzer

Read a JVM garbage-collection log and get throughput, pause percentiles, pause time by cause, full GCs, allocation rate and a heap trend, with the rule behind every finding.

Input

Log

Java GC Log Analyzer

Operator: Abdulla Al Fahad. How tools are built and checked

A garbage-collection log is the plainest record of how a JVM spends its memory budget: every collection, how long the application stopped, and how much heap was left afterwards. Read in the right order it answers three questions that matter in production. Are pauses too long for the service? Are there full collections that should not be there? Is the heap that survives each collection creeping upwards?

This page reads the log from the JVM's own logging, both the unified format of JDK 9 and later (-Xlog:gc*) and the JDK 8 PrintGCDetails layouts, for G1, Parallel, Serial, CMS, ZGC and Shenandoah. It reports throughput, pause percentiles, pause time by cause, full collections and why they happened, allocation rate, a heap trend, humongous allocations, concurrent phase durations and safepoints, charts them on one time axis, and lists the findings with the threshold that triggered each.

Key features

  • Unified logging with uptime or date decorations, and JDK 8 date-stamped and uptime-stamped logs
  • Collector-specific forms: G1 pauses, mixed and full collections, remark and cleanup; Parallel, Serial and CMS pauses; ZGC and Shenandoah pause phases
  • Throughput, pause count and total time, p50, p90, p99 and maximum, and pause time grouped by the cause the JVM states
  • Full collections counted with their causes, and an allocation rate and heap-growth figure from the heap sizes in the log
  • Heap after each collection on a timeline with a leak trend in megabytes per hour, and metaspace after collection when the log has it
  • G1 humongous-allocation collections, to-space exhausted events, concurrent cycle durations and safepoint times when they are logged
  • Several rotated files merged in time order, an events CSV and a self-contained HTML report

Supported log layouts and how the numbers are defined

A unified log line looks like [2.345s][info][gc] GC(12) Pause Young (Normal) (G1 Evacuation Pause) 245M->38M(512M) 8.123ms. The bracketed groups before the tags are decorations; the parser reads a date, an uptime in seconds, milliseconds or nanoseconds, or both. If a log has neither, collections are still counted and timed, but throughput, rates and trends are not available, and the report states that.

JDK 8 logs with -XX:+PrintGCDetails put the pause on one line, for example [GC (Allocation Failure) [PSYoungGen: 33280K->5088K(38400K)] 33280K->24456K(125952K), 0.0118320 secs], and for G1 add a heap summary line below. The whole-heap sizes are taken, not those of the generations. A full collection with a metaspace section is handled the same way.

Files up to 100 MB are read, 40 files and 300 MB in all, and up to 3 million lines. Lines that mention GC but match no known pattern are counted and the first one is quoted, so a collector or flag the page does not know shows up as a number. OpenJ9 verbose GC XML is not read.

The collector is taken from the log's own text, such as Using G1 or the names of the generations, and appears in the summary line. When it cannot be told, the rules for full collections apply to a concurrent collector.

How it works

A pause is a stop-the-world event with a duration. For ZGC and Shenandoah the short pauses of each cycle, such as Pause Mark Start, are counted one by one. Throughput is 100 times one minus the total pause time over the elapsed time, which runs from JVM start when the log begins within the first 5 seconds of uptime and from the first event otherwise.

The allocation rate is the heap growth between the end of one collection and the start of the next, divided by the time between them with the pause taken out. The heap growth after young collections is the increase of the heap-after value from one young collection to the next, an upper bound on promotion because survivors are included.

The leak trend is a least-squares line through the heap after full collections when there are at least five of them. Otherwise the lowest heap-after value in each of 12 blocks of the log is used. It is reported only with its R² and the number of points.

Findings are rules with fixed thresholds: throughput under 95%; any full collection with a collector that normally avoids them, or full collections taking over 30% of pause time with Parallel or Serial; a 99th-percentile pause over 200 ms, or over 10 ms for ZGC and Shenandoah; two or more collections caused by the metaspace threshold; any to-space exhausted event; ten or more humongous-triggered collections; heap after collection rising by over 10 MB an hour with R² of 0.7 or more over at least five points.

When this helps

  • An operator loads a rotated set of four files from a service and reads throughput of 99.1%, so garbage collection is not the cost, then spends the time on the single 392.8 ms full collection.
  • A developer sees G1 Evacuation Pause accounting for 36 pauses and 396.2 ms in the cause table, while the one G1 Compaction Pause takes 392.8 ms, almost as much on its own.
  • A team lead sees a heap-after floor that rises by 400 MB an hour with R² of 0.999 over 20 full collections and opens a heap dump before the next release.
  • An engineer moving a service from JDK 8 to 17 loads both logs and compares p99 pauses and the number of full collections side by side in two sessions.
  • A tuning exercise: setting -XX:InitiatingHeapOccupancyPercent lower, then loading the new log to see whether the to-space exhausted finding has gone.

Opening a file

  1. Drop the log file or the rotated set, paste lines, or load the example.
  2. Check the summary line for the collector and the format, and read any note about unrecognised lines or missing time decorations.
  3. Read the findings, each with its rule.
  4. Look at the pause timeline and the heap-after chart for the shape: regular dots, isolated spikes, or a rising floor.
  5. Open the cause table to see which cause owns most of the pause time.
  6. Download the events CSV or the HTML report.

Example

The page's example: 42 lines of a unified G1 log covering 90 seconds, with 36 young collections, one humongous-triggered concurrent start, a remark, one to-space exhausted and one full collection

Load example. All lines are decorated with uptime in seconds.

Results

39 pauses totalling 812.5 ms in 90 s: throughput 99.10%
Pause p50 11.10 ms, p90 16.20 ms, p99 251.7 ms, maximum 392.8 ms
37 young, 1 full; 1 humongous-triggered collection; 1 to-space exhausted; concurrent mark cycle 880.5 ms
Findings: a full collection with G1; p99 over 200 ms; to-space exhausted

Tips for best results

  • Log with -Xlog:gc*:file=gc.log:time,uptime so both decorations are present; without them throughput and the trend cannot be computed.
  • Compare p99 and the maximum rather than the mean. A mean pause of 20 ms can hide one collection of 400 ms, which is what a user feels.
  • Look at the cause table before the charts: System.gc() and Metadata GC Threshold are the usual avoidable causes of full collections.
  • When the heap-after chart has a sawtooth with a rising floor, the leak trend line will show it; a flat floor with large teeth is a high allocation rate, not a leak.
  • Merge rotated files in one load, not in separate sessions, so that the trend uses the whole run.

Limits

The heap-growth figure after young collections is not the promotion rate. It includes survivor space. The JVM also logs age distributions on gc,age lines and region usage on gc,heap lines, which this page does not read.

Concurrent collectors do part of their work outside pauses. A throughput of 99% says the application was stopped for 1% of the time, not that CPU use for collection was 1%.

A log that starts in the middle of a run, as rotated files do, has no JVM start. Elapsed time then runs from the first event, and the early part of the leak trend may be missing.

Percentiles from a few dozen pauses are noisy. The page computes them from whatever is there, so check the count beside the p99 value.

ZGC and Shenandoah cycles are made of several short pauses. Their pause count is higher than the number of cycles, and their pause times are in the sub-millisecond range.

Common errors and how to fix them

No GC events were recognised.
Use a log from -Xlog:gc* on JDK 9 and later or -XX:+PrintGCDetails on JDK 8. OpenJ9 verbose GC XML and logs with no timing are not read.
The log has 3,400,000 lines; this tool reads up to 3,000,000.
Analyse the rotated files separately or a shorter part of the run.
The files add up to more than 300 MB.
Load fewer rotated files at a time; the newest ones are usually the interesting ones.
gc.log is not a text file (it contains binary data).
A compressed or JFR file was chosen; unpack the log, or use the text log of -Xlog.
The log has no time decorations, so throughput, rates and trends are not available.
Add time and uptime to the -Xlog decorations and take a new log.
3 lines mentioned GC but matched no known pattern and were left out of the numbers.
The first of them is quoted; it is usually a flag-specific line, and the numbers are still right for the lines that were read.

Best practices

  • Keep the exact JVM version and flags with the log; a log without them is hard to read a year later.
  • Compare two logs from the same workload with the same decorations, not logs from different days.
  • Change one flag at a time and load a fresh log for each change.
  • Treat the findings as prompts, since each is a rule on a number and none of them knows your latency target.
  • Read the unrecognised-line note even when the numbers look reasonable.

Reading the cause table

The cause is the text in the last bracket of the pause line, such as G1 Evacuation Pause, G1 Humongous Allocation, Allocation Failure, Ergonomics, System.gc() or Metadata GC Threshold. A pause with no cause, such as a G1 remark, is listed under its own name. Total milliseconds show where the time went; the count shows how often it happened. A cause with a high count and a low total is routine, and one with a count of one and a big total, like the compaction pause in the example, is the event to investigate.

What the findings do not know

A 200 ms 99th-percentile pause is G1's default target, not a limit for your service; a trading system may need 5 ms and a batch job none at all. The rules are fixed, listed beside each finding and in the HTML report, so you can judge whether they apply.

Frequently asked questions

How was the parser checked?

The parser was run on logs written by hand in the documented layouts, with sums I could check. A unified G1 log of seven pauses gave 7 pauses totalling 675.695 ms, equal to adding the numbers in the lines, and 93.243% throughput over 10 s; a JDK 8 Parallel log gave 11.832 ms plus 100 ms, a JDK 8 G1 log 735.3456 ms over four pauses and a CMS log 10.5 ms. Twenty full collections with 20 MB more heap left each 180 seconds gave a trend of exactly 400 MB per hour. These were not logs from real JVM runs, and no comparison with GCViewer or GCeasy was made.

Is my log sent anywhere, given that it may contain host names and paths?

No. The text is read in this tab, only counted and summed, and discarded when you load another. The HTML report you download contains the cause names and numbers, not the log lines, and every cell in it is escaped.

Why does it call a G1 concurrent start a young collection?

The JVM does the same: Pause Young (Concurrent Start) is a young collection that also starts the concurrent mark. It is counted as young, and its cause, for example G1 Humongous Allocation, is the one in the cause table.

Can I load a ZGC log that has no Pause lines?

A ZGC log with only the gc tag lists one line per cycle, with heap before and after but no pauses. Take the log with gc* or gc+phases to get the pause durations.

What counts as a safepoint here?

Lines with the safepoint tag that carry a total time, which the JVM writes with -Xlog:safepoint. The page lists the count, the total, the longest and the five operations that took the most time.

Does a lower throughput always mean a worse application?

No. It means more of the wall time was in pauses. A batch job may tolerate 90% where a web service cannot, which is why the rule threshold of 95% is stated, not hidden.