DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > How To Do GC Log Analysis?

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.

Ram Lakshmanan user avatar by
Ram Lakshmanan
CORE ·
Feb. 12, 22 · Java Zone · Tutorial
Like (3)
Save
Tweet
4.45K Views

Join the DZone community and get the full member experience.

Join For Free

Log analysis illustration

Analyzing 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:

  1. Enable GC logs
  2. Measurement duration and environment
  3. 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:

  1. GCeasy
  2. IBM GC and Memory Visualizer
  3. HP Jmeter
  4. Garbage Cat

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. 

garbage collection

Published at DZone with permission of Ram Lakshmanan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Caching Across Layers in Software Architecture
  • SQL Database Schema: Beginner’s Guide (With Examples)
  • How to Build a Simple CLI With Oclif
  • Writing Beautiful, Optimized, and Better .NET Code With NDepend Static Analysis

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo