Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: What is garbage collection log? How to enable & analyze?

  1. #1
    Member
    Join Date
    Nov 2017
    Location
    USA
    Posts
    148
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default What is garbage collection log? How to enable & analyze?

    Garbage collection has more profound impact on the application in contrary to what most engineers think. In order to optimize memory and garbage collection settings and to troubleshoot memory-related problems, one has to analyze Garbage Collection logs.

    Enabling GC logs
    GC Logging can be enabled by passing below-mentioned system properties during application startup

    Until Java 8:

    Below is the system property that is supported by all version of Java until JDK 8.

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

    From Java 9:


    Below is the system property that is supported by all version of Java starting from JDK 9.

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

    How to analyze GC logs?

    Here is a sample GC log generated when above system properties were passed:

    what-is-gc.jpg

    GC log has rich information, however, understanding GC log is not easy. There isn’t sufficient documentation to explain GC log format. On top of it, GC log format is not standardized. It varies by JVM vendor (Oracle, IBM, HP, Azul, …), Java version (1.4, 5, 6, 7, 8, 9), GC algorithm (Serial, Parallel, CMS, G1, Shenandoah), GC system properties that you pass (-XX:+PrintGC, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintHeapAtGC …). Based on this permutation and combination, there are easily 60+ different GC log formats.

    Thus, to analyze GC logs, it’s highly recommended to use GC log analysis tools such as GCeasy, HPJmeter. These tools parse GC logs and generate great graphical visualizations of data, reports Key Performance Indicators and several other useful metrics.
    Last edited by Ram Lakshmanan; September 23rd, 2018 at 12:04 AM.

Similar Threads

  1. Replies: 1
    Last Post: November 28th, 2017, 05:17 AM
  2. Question about garbage collection
    By dudushr in forum Java Theory & Questions
    Replies: 6
    Last Post: October 31st, 2013, 02:22 AM
  3. Replies: 1
    Last Post: June 12th, 2013, 12:58 PM
  4. Java Garbage Collection and destructors
    By riddhik84 in forum Java Theory & Questions
    Replies: 5
    Last Post: October 1st, 2009, 09:06 AM
  5. Garbage Collection?
    By kalees in forum Collections and Generics
    Replies: 6
    Last Post: September 23rd, 2009, 03:07 AM

Tags for this Thread