Core Java

How to do GC Log analysis?

Analyzing garbage collection log provides several advantages like: Reduces GC pause time, reduces cloud computing cost, predicts outages, provides effective metrics for capacity planning. To learn about the profound advantages of GC log analysis, please refer to this post. In this post let’s learn how to analyze GC logs?

Basically, there are 3 essential steps when it comes to GC log analysis:

1. Enable GC logs

2. Measurement Duration & Environment

3. Tools to analyze

Let’s discuss these 3 steps now.

1. Enable GC Logs

Even though certain monitoring tools provide Garbage Collection graphs/metrics at real time , they don’t provide a complete set of details to study the GC behavior. GC logs are the best source of information, to study the Garbage Collection behavior. You can enable GC logs, by specifying below JVM arguments in your application:

Java 8 & below versions:

If your application is running on Java 8 & below versions, then pass below arguments:

-XX:+PrintGCDetails -Xloggc:<gc-log-file-path>
Example:
-XX:+PrintGCDetails -Xloggc:/opt/tmp/myapp-gc.log

Java 9 & above versions:

If your application is running on Java 9 & above versions, then pass below arguments:

-Xlog:gc*:file=<gc-log-file-path>
Example:
-Xlog:gc*:file=/opt/tmp/myapp-gc.log

2. Measurement Duration & environment

It’s always best practice to study the GC log for a 24-hour period during a weekday, so that application would have seen both high volume and low volume traffic tide. 

It’s best practice to collect the GC logs from the production environment, because garbage collection behavior is heavily influenced by the traffic patterns. It’s hard to simulate production traffic in a test environment. Also overhead added by GC log in production servers is negligible, in fact it’s not even measurable. To learn about overhead added by enabling GC logs, you can refer here.

3. Tools to analyze

Once you have captured GC logs, you can use one of the following free tools to analyze the GC logs:

  1. GCeasy
  2. IBM GC & Memory visualizer
  3. HP Jmeter
  4. Garbage Cat

Here is an interesting video clip which walks through the best practices, KPIs, tips & tricks to effectively optimize Garbage collection performance.

Published on Java Code Geeks with permission by Ram Lakshmanan, partner at our JCG program. See the original article here: How to do GC Log analysis?

Opinions expressed by Java Code Geeks contributors are their own.

Ram Lakshmanan

Ram Lakshmanan developed world's finest DevOps tools: GCeasy.io, fastThread.io, HeapHero.io. Every single day, millions & millions of people in North America—bank, travel, and commerce—use the applications that Ram Lakshmanan has architected. Ram is an acclaimed speaker in major conferences on scalability, availability, and performance topics. Recently, he has founded a startup, which specializes in troubleshooting performance problems.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button