How To Do GC Log Analysis?
In this post, we will discuss the benefits of analyzing the garbage collection logs, essential steps to conduct GC log analysis, and some free tools to analyze.
Join the DZone community and get the full member experience.
Join For FreeAnalyzing garbage collection logs provides several advantages like it 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:
- Enable GC logs
- Measurement duration and environment
- Tools to analyze
Let’s discuss these steps in detail.
1. Enable GC Logs
Even though certain monitoring tools provide real-time Garbage Collection graphs/metrics, 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 and Below Versions
If your application is running on Java 8 and below versions, then pass the following arguments:
-XX:+PrintGCDetails -Xloggc:<gc-log-file-path>
Example:
-XX:+PrintGCDetails -Xloggc:/opt/tmp/myapp-gc.log
Java 9 and Above Versions
If your application is running on Java 9 and above versions, then pass the following arguments:
-Xlog:gc*:file=<gc-log-file-path>
Example:
-Xlog:gc*:file=/opt/tmp/myapp-gc.log
2. Measurement Duration an Environment
It’s always best practice to study the GC log for a 24-hour period during a weekday so that the 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 traffic patterns. It’s hard to simulate production traffic in a test environment. Also, the 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 read my previous post.
3. Tools To Analyze
Once you have captured GC logs, you can use one of the following free tools to analyze the GC logs:
Furthermore, here is an interesting video clip that walks you through the best practices, KPIs, tips, and tricks to help you effectively optimize Garbage collection performance.
If you use any other tool or method to conduct your GC analysis, feel free to share them in the comments below.
Published at DZone with permission of Ram Lakshmanan, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments