GC Logging Analysis: Decoding JVM Garbage Collection Logs
Master JVM garbage collection log analysis with -Xlog:gc, GCEasy, and GCViewer. Practical guide to diagnosing memory issues and tuning performance.
Master JVM garbage collection log analysis with -Xlog:gc, GCEasy, and GCViewer. Practical guide to diagnosing memory issues and tuning performance.
GC Logging Analysis: Decoding JVM Garbage Collection Logs
This guide focuses on HotSpot JVM garbage collection logs. The examples use unified logging, introduced in Java 9; check the documentation for the JDK release you run because available tags and details can differ.
GC logs help connect pauses and heap changes to latency or memory symptoms. They are most useful when read alongside request latency, allocation rate, deployment changes, and the workload that produced them.
Introduction
Start with a small gc=info log configuration, then collect more detail when a question calls for it. Use the same baseline in development, staging, and production when you need comparable behavior. Detailed gc* debug or trace output can increase CPU and storage load, so enable it for a bounded investigation and compare its overhead under a representative workload.
A reasonable production starting point is to keep a rotating log with enough retention to cover the incident window. Storage limits, log volume, container logging, and the service’s observability policy determine the final settings; there is no single level that suits every JVM.
Architecture of JVM Garbage Collection
Understanding how the JVM organizes memory helps you interpret GC logs effectively.
graph TD
subgraph "JVM Heap Memory"
subgraph "Young Generation"
ED[Eden<br/>New objects allocated here]
S0[Survivor Space 0<br/>Survivors from Eden]
S1[Survivor Space 1<br/>Survivors from S0]
end
subgraph "Old Generation"
OG[Old Generation<br/>Long-lived objects promoted]
end
subgraph "Metaspace"
MS[Metaspace<br/>Class metadata, no GC]
end
end
ED -->|"Minor GC<br/>Copying survivors"| S0
S0 -->|"Aging"| OG
S0 <-->|"Copying during GC"| S1
ED -->|"Major/Full GC<br/>Mark-Compact"| OG
The diagram shows the generational memory architecture. Objects allocate in Eden, survive minor GCs in survivor spaces, and eventually promote to the old generation. Understanding this flow helps you interpret why certain GC events occur and what they mean for your application.
Enabling GC Logging
HotSpot JDK 9 and later use the unified logging framework. The following JDK 21 example records basic GC messages and rotates local files:
java -Xlog:gc=info:file=gc.log:time,uptime:filecount=5,filesize=50M -jar your-application.jar
Use more tags only when the diagnosis needs them. This example captures GC-related tags at info level and keeps five files, each up to 50 MB:
java -Xlog:gc*=info:file=gc.log:time,uptime,tags:filecount=5,filesize=50M -jar your-application.jar
For a short investigation, increase the level only after checking expected volume and overhead:
java -Xlog:gc*=debug:file=gc-debug.log:time,uptime,tags:filecount=3,filesize=50M -jar your-application.jar
The filecount and filesize output options rotate the JVM’s local log files. They do not define retention in a log collector or object store; set that retention separately. In containers, you can write to stdout and let the platform’s logging agent handle rotation:
java -Xlog:gc=info:stdout:time,uptime,tags -jar your-application.jar
Before uploading logs, review them for absolute paths, hostnames, JVM arguments, and workload timing or allocation details. Limit access and retention to the people and period needed for the investigation. The format and options above follow the JDK 21 unified logging documentation.
Understanding GC Log Output
A typical minor GC event looks like this:
[2026-05-26T10:15:32.145+0000][29845.432][gc ] GC(12) Pause Young (Normal)
GC(12) Heap before: used=245M, committed=512M, allocated=512M
GC(12) young: 245M -> 0B; [Metaspace: 48M -> 48M]
GC(12) Heap after: used=89M, committed=512M, allocated=512M
GC(12) old: 67M -> 89M; [Metaspace: 48M -> 48M]
This shows a minor GC that reclaimed 156 MB from the young generation. The old generation grew slightly from 67 MB to 89 MB because some long-lived objects survived. The pause lasted long enough to be logged but was not severe enough to cause concern.
A Full GC event requires more attention:
[2026-05-26T10:15:45.678+0000][29858.965][gc ] GC(13) Pause Full (Allocation Failure)
GC(13) Heap before: used=471M, committed=512M, allocated=512M
GC(13) metaspace: 52M -> 52M
GC(13) Heap after: used=156M, committed=512M, allocated=512M
GC(13) old: 423M -> 108M; [Metaspace: 52M -> 52M]
Full GCs occur when the old generation cannot accommodate an allocation request or when the permanent generation fills. The pause time on Full GCs is typically an order of magnitude greater than minor GCs, making them the primary culprit in latency-sensitive applications.
GC Log Analysis Tools
GCEasy
GCEasy is a web-based tool that accepts uploaded GC logs and produces detailed analysis. It identifies the GC algorithm in use, calculates pause times and throughput, detects memory leak trends, and provides actionable recommendations.
For logs stored in a file:
# Upload to GCEasy (requires API key for automation)
curl -F "file=@gc.log" https://api.gceasy.io/analyzeGC
# Or use the web interface
# https://gceasy.io
GCEasy excels at identifying problems that require experience to spot. It recognizes patterns like “metaspace exhaustion,” “allocation rate spikes,” and “degenerate GCs” that indicate collector misconfiguration.
What GCEasy shows you depends on the logging level you enabled. With basic -Xlog:gc=info, GCEasy extracts pause times, GC cause, and memory usage. Crank it up to -Xlog:gc*=trace and it reconstructs the full GC timeline: concurrent phases, reference processing duration, card table flush times. The more detail you capture, the richer the analysis.
The tool organizes findings into tabs. The GC Stats tab aggregates key metrics across all GC events: total GC time, longest pause, average pause, throughput percentage. The Heap Dump tab plots heap usage over time so you can spot the sawtooth pattern of a healthy minor GC versus the staircase climb of a memory leak. The Cause Graph tab maps GC cause to frequency, helping you distinguish normal allocation-driven GC from pathological triggers like “Last_ditch_collection” or “Allocation Failure” firing dozens of times per minute.
GCEasy also generates a recommendations section that reads like a GC tuning cheat sheet. It suggests heap size adjustments, flags excessive Full GC frequency, and recommends collector switches based on your pause time targets. Treat these as starting points, not gospel—validate recommendations against your actual workload before applying them.
Here is a practical workflow: pull the GCEasy URL from the API response and embed it in your incident management tool. When an alert fires, the analyst gets the full GC report without manually uploading logs or opening a browser. This matters at 3 AM when speed matters more than learning the tool from scratch.
GCViewer
GCViewer is an open-source desktop tool for visualizing GC logs. It renders charts showing heap usage over time, pause time distribution, and throughput calculations.
# Download from GitHub releases
wget https://github.com/chewiebug/GCViewer/releases/download/v1.34.1/standalone-javafx-1.34.1.jar
# Run with Java 11+
java -jar gcviewer-1.34.1.jar gc.log
Key metrics GCViewer provides include total pause time, average pause time, maximum pause time, and throughput percentage. The visual representation makes it easy to spot problem periods that correlate with application behavior or deployment events.
Reading the GCViewer charts takes some familiarity with what each view shows. The heap usage chart plots used memory against time on the Y-axis, with one line per heap generation. A healthy minor GC pattern shows a repeating spike-and-dip waveform on the young generation line. The old generation line should stay relatively flat if your application has stable live data. If it climbs steadily after each Full GC, you have a promotion or leak problem. The pause time chart renders each GC pause as a vertical bar. Height matters more than width here, a tall bar means a long pause. Clustered tall bars during specific time windows point directly at GC causing latency spikes in your application.
GCViewer also provides a throughput gauge. The math is simple: (total_time - total_gc_pause_time) / total_time. Below 90% and you have a GC problem worth investigating. Below 80% and you are losing more than a fifth of your CPU to memory management, which is a significant tax on your application’s efficiency.
GCViewer has one advantage over GCEasy: comparing two log files side by side. Run your application with the old settings for an hour, then with the new settings, and load both logs into GCViewer. The comparison view overlays heap usage and pause time, making it immediately obvious whether the tuning helped. This is the fastest way to validate a hypothesis before committing a change to production.
The tool exports data as CSV, which comes in handy if you want to feed GC metrics into your own dashboards or build custom analysis that GCViewer does not support natively. Pair it with Grafana and you have a homegrown GC monitoring solution that never sends sensitive logs to external services.
Other Tools
Beyond GCEasy and GCViewer, a few other tools fill specific niches.
GCPlot is for teams that want programmatic access to GC metrics. It runs as a self-hosted server or cloud service, accepting log uploads via API and exposing metrics through a dashboard. If you already use Grafana or Prometheus, you can wire GCPlot data through its REST API. It supports threshold alerting on pause times and throughput drop.
IBM GC Extension for Health Center targets WebSphere and IBM JVM environments. It pulls GC data alongside CPU, memory, and I/O metrics into one view, so you can see GC behavior in the context of system resource consumption. On AIX or Windows servers running traditional IBM Java stacks, this gives you more relevant data than generic tools.
Amazon Corretto bundles its own diagnostic commands and hooks into AWS CloudWatch. The jcmd utility that comes with Corretto exposes GC cause and phase information, which pairs naturally with CloudWatch dashboards. If you run Java on EC2 or containers in AWS, the built-in diagnostics cover most steady-state monitoring needs without third-party tools.
Caution on External Tools: Uploading production GC logs to external services exposes your application’s memory patterns, class names, and potentially sensitive data to networks you do not control. Before sending logs to a tool like GCEasy, check their data retention policy and confirm your compliance requirements allow it.
Production Failure Scenarios
Scenario 1: Continuous Full GC Due to Memory Leak
A production service suddenly starts experiencing Full GC every few minutes. The old generation fills up immediately after each Full GC, causing another. This classic pattern indicates objects leaking into the old generation—typically caches without eviction, static collections, or object pools that grow unboundedly.
Look for Full GC events firing in rapid succession, often with the same GC cause repeated. The old generation memory shows no meaningful reduction after each collection. Compare consecutive Full GC entries:
[2026-05-26T14:23:01.123+0000][48234.556][gc] GC(47) Pause Full (Allocation Failure)
GC(47) Heap before: used=489M, committed=512M, allocated=512M
GC(47) Heap after: used=156M, committed=512M, allocated=512M
GC(47) old: 441M -> 108M
[2026-05-26T14:23:45.891+0000][48278.324][gc] GC(48) Pause Full (Allocation Failure)
GC(48) Heap before: used=471M, committed=512M, allocated=512M
GC(48) Heap after: used=152M, committed=512M, allocated=512M
GC(48) old: 423M -> 104M
Notice the old generation sits at 423-441 MB before each Full GC despite reclaiming 330+ MB each time. This means roughly 400 MB of live objects return to the old generation almost immediately. After several cycles with no relief, a memory leak is confirmed.
To diagnose, capture heap dumps at two points during leak progression using jcmd <pid> GC.heap_dump heap_before.hprof and again after a few more Full GCs. Compare the dumps with jhat or VisualVM to find object instances that grew significantly. Run jmap -histo:live <pid> after a Full GC to see the histogram of live objects, looking for unexpected class names or large primitive arrays. Enable object allocation tracking with -XX:TLABSize=512k -XX:+HeapDumpOnOutOfMemoryError to capture where leaked objects originate.
Common sources of leaks: unbounded caches using ConcurrentHashMap without size limits. Static List, Map, or Set collections populated at runtime and never cleared. Connection pools with no max size. ThreadLocal instances not removed in web applications. Object pools for reuse that accumulate rather than release.
Scenario 2: GC Thrashing Under High Allocation Rate
An application with bursty traffic experiences severe performance degradation during traffic spikes. GC logs show extremely frequent minor GCs with high allocation rates, sometimes followed by Full GCs when the young generation cannot keep up.
The defining characteristic is a high ratio of minor GCs to application time. You see “Pause Young (Normal)” events firing every few seconds or more. The survivor spaces fill up fast, and objects promote prematurely to the old generation.
[2026-05-26T15:04:12.234+0000][51234.123][gc] GC(89) Pause Young (Normal)
GC(89) Heap before: used=478M, committed=512M, allocated=512M
GC(89) young: 478M -> 0B
GC(89) Heap after: used=67M, committed=512M, allocated=512M
GC(89) old: 411M -> 467M; [Metaspace: 52M -> 52M]
The old generation promotion line tells the story: 411 MB promoted to 467 MB during a single minor GC. That is 56 MB of objects that should have died in the young generation. Over time, the old generation fills, triggering Full GCs under allocation pressure.
Compare allocation and promotion rates across representative load windows, then correlate them with survivor occupancy, old-generation growth, and pause time. A promotion spike can mean the young generation or survivor capacity is constrained, but the log alone does not establish which setting to change. Use GCViewer to inspect the pattern and compare it with application allocation behavior.
Treat generation sizing, survivor settings, and tenuring thresholds as hypotheses. First check whether the deployed collector and JDK use each option; for G1, Oracle advises against pinning young-generation size when it interferes with pause control. Change one supported setting only when the logs point to that constraint, then compare promotion, pauses, throughput, and peak RSS under the same workload. If heap pressure continues, investigate the live set and object retention rather than stacking more flags.
Scenario 3: Metaspace Exhaustion
Modern applications using reflection, dynamic proxies, or heavy classloading can exhaust Metaspace. Before Java 8, this would have been PermGen space. Metaspace grows dynamically but garbage collects classloaders when they become unreachable.
Logs show Metaspace increasing steadily, then hitting the configured limit. If MaxMetaspaceSize is set too low, you will see “OutOfMemoryError: Metaspace” errors.
How to identify it: Watch the Metaspace line in GC output. If it grows continuously with no corresponding decrease after GC, you have metaspace pressure. Heap memory typically reclaims space after collection; metaspace does not behave the same way. When Metaspace: used=X -> Y shows Y getting close to the configured maximum with no relief after classloader GC phases, you are hitting the ceiling.
Common culprits: ORM frameworks like Hibernate generate proxy classes at runtime. Serialization libraries like Kryo or Jackson create class variants for generic types. JSP compilers load a new classloader per page compilation. Dynamic proxies via java.lang.reflect.Proxy and bytecode manipulation libraries like ASM, CGLIB, or javassist all add classloader pressure. After a hot redeployment, old classloaders sometimes linger because static references keep them alive.
Diagnosis steps: Run jcmd <pid> VM.native_memory summary to see the native memory breakdown. Use jmap -clstats <pid> to list loaded classes and their classloaders. On JDK 9 and later, use unified logging such as -Xlog:class+load=info when you need to inspect class loading; check the current JDK documentation for supported tags. Compare metaspace usage before and after redeployments; if it grows with each deploy, investigate classloader retention.
Remediation: Raise -XX:MaxMetaspaceSize only if a deliberately low cap is the problem; it does not repair classloader retention. For leaks, trace which classloaders remain reachable after redeployment and remove the references that keep them alive. Collector changes should follow a workload comparison, not serve as a generic metaspace fix.
Trade-off Table
| Aspect | Minor GC | Full GC | G1 | ZGC |
|---|---|---|---|---|
| Work involved | Usually young-generation collection | May collect and compact old-generation or full-heap regions | Incremental region evacuation with stop-the-world pauses and concurrent work | Mostly concurrent work with short stop-the-world phases |
| Pause behavior | Measure in the application; duration depends on live data and runtime | Can be much longer than a young collection, depending on cause and live data | Tries to meet pause-time goals; not a guarantee | Designed for low pause times; measure with the target JDK and workload |
| Trade-offs | Frequent collections may affect throughput | Can interrupt application work for longer | Balances pause goals and throughput | Uses CPU and memory resources for concurrent work |
| Use when | Your logs show young-generation behavior to investigate | Your logs show full-collection pressure | Its pause and throughput behavior fits the service objective | Its measured behavior fits a strict pause objective |
Implementation Snippets
Analyzing GC Logs Programmatically
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.*;
public class GcLogAnalyzer {
// Pattern for pause time extraction
private static final Pattern PAUSE_PATTERN =
Pattern.compile("Pause (Young|Old|Full).*?(\\d+\\.\\d+)ms");
public static void main(String[] args) throws Exception {
double totalPauseTime = 0;
int gcCount = 0;
try (BufferedReader reader = new BufferedReader(
new FileReader("gc.log"))) {
String line;
while ((line = reader.readLine()) != null) {
Matcher matcher = PAUSE_PATTERN.matcher(line);
if (matcher.find()) {
double pauseTime = Double.parseDouble(matcher.group(2));
totalPauseTime += pauseTime;
gcCount++;
System.out.printf("GC #%d: %.2fms%n", gcCount, pauseTime);
}
}
}
System.out.printf("%nTotal GC pauses: %d%n", gcCount);
System.out.printf("Average pause: %.2fms%n", totalPauseTime / gcCount);
System.out.printf("Total pause time: %.2fms%n", totalPauseTime);
}
}
Automated Log Upload
At scale, manually uploading logs to GCEasy does not scale. Automating the pipeline lets you analyze GC logs continuously without someone doing it by hand.
When to automate: If you produce more than 1 GB of GC logs per day, manual analysis is not sustainable. Scheduled uploads every few hours, or triggered after each log rotation, keep your analysis current. Teams working incidents can also fire an upload immediately from CI/CD hooks or monitoring alerts.
Script mechanics: The bash script checks if the log file exists before attempting upload, which prevents failures from missing files. The API key authenticates your request to GCEasy’s server. The response JSON contains a gceasyUrl field with a link to the analyzed report, or an error field if something went wrong. Using jq -r to extract the field handles both cases cleanly.
#!/bin/bash
# Upload recent GC logs to GCEasy for analysis
LOG_FILE="gc-production.log"
if [ -f "$LOG_FILE" ]; then
RESPONSE=$(curl -s -F "file=@$LOG_FILE" \
-F "apiKey=YOUR_API_KEY" \
https://api.gceasy.io/analyzeGC)
echo "$RESPONSE" | jq -r '.gceasyUrl // .error'
else
echo "GC log file not found: $LOG_FILE"
fi
Production considerations: Store your API key in a secrets manager, never hardcode it in scripts. Add retry logic with exponential backoff for network failures. Store the gceasyUrl in your incident management system so engineers can access the report without needing GCEasy access themselves. In security-sensitive environments, consider self-hosting GCEasy or using the on-premises version.
CI/CD integration: Wire the upload into your deployment pipeline to automatically analyze GC logs after each production deploy. Correlate the GCEasy report URL with the deployment timestamp in your monitoring dashboard so GC health shows up alongside your standard deployment metrics.
Observability Checklist
Before declaring a GC issue resolved, compare throughput, pause percentiles, GC CPU, heap occupancy, RSS, and allocation or promotion behavior with the service objective and the same workload used for the baseline. Look for repeated Full GCs or unbounded memory growth, then confirm the pattern holds across a representative load cycle.
Monitor these metrics over at least one full load cycle to ensure the patterns observed are consistent and not anomalies.
Security and Compliance Notes
GC logs contain sensitive information about your application’s memory usage patterns. Object class names can reveal implementation details, and string content in objects may expose user data or internal system information. Protect GC logs accordingly—encrypt them at rest and restrict access to operations and performance teams.
In regulated industries, GC logs may fall under operational audit requirements. Document why you enabled specific logging levels and retain logs according to your data retention policy.
Never expose GC log analysis tools to untrusted networks. Tools like GCEasy process sensitive memory data; ensure you understand their data handling policies before uploading production logs.
Common Pitfalls / Anti-Patterns
The most frequent mistake is enabling too much logging in production. Verbose GC logging with all tags enabled creates significant overhead and generates enormous log volumes. Start with minimal logging and add tags only when investigating specific issues.
Another common error is analyzing logs from the wrong time window. GC behavior during application startup differs dramatically from steady-state operation. Always compare logs from similar application lifecycle phases.
Misinterpreting Full GC causes leads to ineffective solutions. Not every Full GC indicates a problem. Some Full GCs are normal—metaspace garbage collection, or Java heap dumps triggered programmatically, or System.gc() calls from application code.
Finally, tuning GC without load testing produces misleading results. What works under test load may fail under production traffic patterns. Always validate GC tuning changes with realistic workloads.
Quick Recap Checklist
- Start with
-Xlog:gc=infoand add tags or verbosity to answer a specific question - Configure rotation with
filecountandfilesize, then set retention separately in the logging platform - Compare logs from similar workload and lifecycle windows
- Correlate GC events with application latency, allocation, and deployment changes
- Treat uploaded logs as operational data; review paths, hostnames, and workload details first
Interview Questions
A young collection processes the young generation, moving survivors between survivor regions or promoting them. Its duration depends on the collector, live data, heap configuration, and workload.
A Full GC can collect and compact a larger portion of the heap and can pause the application for longer than a young collection. The exact cause and duration depend on the collector and runtime. Repeated Full GCs are a reason to inspect heap pressure, allocation, promotion, and the live set.
Look for a pattern where the old generation usage continuously increases over time without corresponding decreases after Full GC events. If after multiple Full GCs the old generation never shrinks back down, objects are leaking into it.
Steps: First, enable verbose GC logging. Second, analyze the old generation usage trend over several days using GCEasy or GCViewer. Third, generate heap dumps at two points in time and compare them to identify growing object graphs. Fourth, use jmap -histo to find unexpectedly large object arrays or class instance counts. Common culprits include static collections, caches without size limits, unbounded object pools, and unclosed resources like database connections stored in instance variables.
For HotSpot JDK 9 and later, unified logging can write a rotating local file: -Xlog:gc=info:file=/path/to/gc.log:time,uptime:filecount=5,filesize=50M. The file-count and file-size options rotate the JVM log; set collection retention separately.
Avoid overly verbose settings like gc*=trace in production because the overhead impacts performance and generates excessive data. For Java 8 and earlier, the equivalent is -XX:+PrintGCTimestamps -XX:+PrintGCDetails -Xloggc:/path/to/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=50M.
It indicates a minor GC event in the young generation that completed normally. "Pause" refers to the stop-the-world pause that occurs when application threads are temporarily halted for the GC to operate safely. "Young" confirms the collection targeted the young generation. "Normal" means the collection succeeded without issues like promotion failure.
The log shows before and after heap states: Heap before: used=245M to Heap after: used=89M tells you how much memory was reclaimed. The old generation line shows promotion during the minor GC—some objects were old enough to promote rather than die.
Several indicators suggest GC tuning is the solution. Throughput remains below SLA despite optimal code—GC overhead is consuming the budget. Pause times exceed latency SLAs even with healthy application code. The old generation grows continuously but holds mostly long-lived, legitimately cached data that application code cannot reduce.
If heap usage is stable and reasonable after warmup but GC runs too frequently, increasing heap or adjusting generation ratios helps. If allocation rate analysis shows short-lived objects promoting unnecessarily, tuning survivor space ratios helps. If pauses cluster during specific operations, the allocation profile may need adjusting rather than code changes.
G1GC logs show "Pause Young" and "Pause Full" events with region-level detail showing which regions were collected and how much memory was reclaimed per region type. The output includes heap state before and after with young/old generation breakdowns.
ZGC logs show concurrent phases: "Pause Remroot," "Concurrent Move," "Concurrent Mark," etc. Because ZGC is mostly concurrent, its pauses are much shorter. The logs reveal which phases caused the brief stop-the-world moments and the throughput impact of concurrent phases.
The time keyword in -Xlog adds wall-clock timestamps (ISO 8601 format). The uptime keyword adds seconds since JVM start. For correlating GC events with application behavior, uptime is more useful because it is independent of system clock changes or log rotation.
To correlate, match GC pause times from logs against application metrics (request latency spikes, throughput drops) and deployment events (app restarts, config changes). A GC pause that aligns with a latency spike confirms it as the root cause.
With collectors that use concurrent marking, a concurrent cycle may fail to reclaim space before the application needs it, leading to a stop-the-world Full GC. The cause can be allocation rate, live-set size, available heap, or collector behavior; inspect the event and surrounding log data before deciding what to change. CMS was removed from current JDK releases, so its log messages apply only to older runtimes.
For G1, use the release-specific GC tuning guide to interpret the log and form a hypothesis. Compare any supported heap or collector setting against the same workload rather than applying a generic flag.
Allocation Failure is the most common reason for a young generation GC. It occurs when a thread tries to allocate an object in the young generation but finds no space. This triggers a minor GC to free space. This is normal behavior, not a problem—the term "failure" here means the allocation attempt failed and triggered GC, not that something went wrong.
High frequency of Allocation Failure followed by Full GC (Allocation Failure) indicates memory pressure where objects are promoting too quickly or the young generation is too small.
GC overhead = (Total GC pause time / Total application uptime) * 100. GCViewer calculates this automatically. A healthy application typically shows less than 5% GC overhead. Above 10% indicates GC is consuming too much application time.
For example, if your application runs for 1 hour (3,600,000ms) and accumulates 180,000ms of GC pause time, overhead is 5%. This calculation helps set GC tuning goals and measure improvement after tuning changes.
Metaspace stores class metadata and is separate from the Java heap. Increasing metaspace with stable heap indicates classloader memory growth—typically from dynamic class generation, reflection-heavy frameworks, or a classloader leak after redeployment. This is different from heap memory leaks and requires analysis of classloader retention, not object retention.
Check for frameworks that generate classes dynamically: ORM systems, serialization libraries, JSP compilers, scripting engines. If metaspace grows continuously without stabilising, increase -XX:MaxMetaspaceSize or investigate why classloaders are not being garbage collected.
Some collectors report a degenerated or fallback collection when concurrent work cannot keep up with allocation or reclaim enough space. The exact event name and behavior depend on the collector and JDK. Treat it as a signal to inspect allocation rate, live-set growth, heap headroom, and collector logs rather than as proof that one particular flag is wrong.
Use those measurements to decide whether a heap, application, or collector change is worth testing. A collector switch may help one workload and create a throughput or memory trade-off in another.
If after every Full GC the old generation quickly returns to near-full capacity, the heap is too small for the application's live set. If the young generation is too small, minor GCs occur very frequently with high allocation rates. If survivor spaces are consistently full after minor GC, objects are promoting before they should.
Look at the "Heap after" values for each GC type and compare them to "Heap before" to see how much headroom exists. A healthy GC pattern shows stable used memory after GCs with room to grow before the next collection.
Shenandoah logs show concurrent GC phases similar to ZGC but with different naming. You will see "Pause Init" (initial marking), "Concurrent Mark," "Pause Final Mark," and "Concurrent Cleanup." The key difference from G1 is that Shenandoah performs evacuations (moves objects) concurrently rather than during stop-the-world pauses.
The critical metric in Shenandoah logs is the evacuation pause times—these should be consistently sub-millisecond. If evacuation pauses grow large, it indicates issues with the collection set or memory layout.
GC logs rotate based on filecount (number of files to keep) and filesize (size threshold for rotation). Tools like GCViewer and GCEasy handle rotated logs differently: GCViewer can process multiple files if provided as arguments or merged, while GCEasy may process only the most recent file.
For continuous production monitoring, use a cron job or log shipper to process rotated files and feed them into a centralized system. Never rely solely on the currently active log file—it may not contain enough historical context for meaningful analysis.
The number in parentheses represents the GC cycle ID, an incrementing counter across the JVM lifetime. Tracking GC cycle IDs helps correlate events across log timestamps. If GC(12) is followed by GC(15), you know some cycles were not logged at the verbosity level you selected. The ID also helps track how many GCs occurred between events you are investigating.
Establish a baseline by measuring current GC overhead percentage, average pause time, and maximum pause time. After tuning changes, compare these metrics. Success criteria: GC overhead reduced below 5% (from higher), average pause time reduced to within your SLA target, and no continuous Full GC cycles. Run the workload long enough to capture representative behavior before declaring success.
The "Old Gen" line in GC log output shows how much memory was promoted from young to old generation during the GC. For minor GCs, it shows old generation before and after values. Rapid old generation growth indicates objects promoting too quickly, which could mean survivor spaces are too small or objects have too long a lifespan for your young generation sizing.
The GC cause field (e.g., "Allocation Failure", "G1 Evacuation Pause", "Heap Dump") explains why the GC was triggered. Common causes include Allocation Failure (young gen full), Heap Dump (triggered by jmap or similar), System.gc() (explicit call), and Metaspace GC (classloader cleanup). Unusual causes or frequent triggers help diagnose whether GC is working as expected or if something is causing excessive GC.
For capacity planning, track old generation growth rate over time. If old gen usage grows consistently after each Full GC, you have a memory leak. Calculate the growth rate in MB/hour to predict when the heap will be insufficient. Also analyze allocation rate (bytes/second being allocated) to determine minimum heap needed for your workload. Historical GC data helps size heaps for future traffic growth.
Further Reading
- JVM Flags Explained — Configure the flags that generate the logs analyzed here
- Java Mission Control — Advanced flight recording analysis for deeper JVM diagnostics
- GCEasy: Free Online GC Log Analyzer — Upload GC logs for automated analysis and recommendations
- Oracle Java Docs: GC Tuning Guide — Official GC tuning documentation
- GCViewer on GitHub — Open-source desktop visualization tool for GC logs
- Advanced Java & JVM Internals Roadmap — Parent roadmap
Conclusion
GC logs are most useful when they answer a concrete question about pauses, allocation, or memory pressure. Keep a small rotating baseline where the service’s storage and privacy policies allow it; collect verbose logs for a bounded investigation. Compare the same workload before changing collector settings, and keep the logs only as long as the investigation needs them.
Category
Related Posts
Heap Walking and Allocation Tracking: TLABs and Analysis
Understand how the JVM allocates memory with TLABs, how to track allocations with low overhead, and how heap walking tools analyze object graphs.
Java atomics and VarHandle: Concurrency in Java 25
Learn Java 25 atomics: AtomicInteger, AtomicReference, CAS loops, LongAdder, VarHandle memory modes, and when to choose an atomic or lock.
JVM Bytecode Verification: Type Checking and Stack Map Frames
A practical guide to JVM bytecode verification by class-file version, including type inference, StackMapTable frames, VerifyError debugging, and verification limits.