Introduction to the use of GC view, a tool for GC log analysis

Thanks for likes and attention, a little progress every day! come on!

Table of contents

1. Introduction to GCViewer 

2. Use of GCViewer

2.1 compile

2.2 use


1. Introduction to GCViewer 


Two tools for analyzing GC logs are more popular in the industry - GCViewer and GCEasy. Some functions of GCEasy still need to be charged. Today I will introduce the use and function of GCViewer to you. Memory Analyzer Mat JVM Analysis


2. Use of GCViewer


2.1 compile

GitHub - chewiebug/GCViewer at 1.36

First, search for the GCViewer project on github and download it locally. The GCViewer project does not provide a ready-made release version. Use the following maven compilation command to complete the compilation of GCViewer and finally generate a gcviewer-1.36.jar.

yum install  -y  git  svn  maven
cd  /hadoop/software/
unzip  GCViewer-1.36.zip
cd  GCViewer-1.36
## maven 编译 操作环境 Linux 
mvn clean install -DskipTests

2.2 use

Double-click the compiled jar

  • Full GC Lines: (full gc)
  • Inc GC Lines: (incremental GC)
  • GC Times Line: (gc time)
  • GC Times Rectangles: (gc time zone)
  • Total Heap: (total heap size)
  • Red line that shows heap size
  • Tenured Generation: (Old Generation)
  • Young Generation: (young generation)
  • Used Heap: (heap usage)
  • Initial mark level: (cms or g1 garbage collection algorithm initial mark event)
  • Concurrent collections: (cms or g1 garbage collection concurrent collection cycle)

Run the Java program to print the GC log, the garbage collector uses G1

/usr/java/jdk1.8.0_144/bin/java \
  -Xmx1024m -Xms1024m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 \
  -XX:-ResizePLAB -verbose:gc -XX:-PrintGCCause -XX:+PrintAdaptiveSizePolicy \
  -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/hadoop/datadir/windeploy/log/ETL/DS/gc.log-`date +'%Y%m%d%H%M'` \
  -classpath xxx.jar

GC logs will be generated in the path /hadoop/datadir/windeploy/log/ETL/DS/, and some of the generated logs are as follows:

2022-11-23T15:33:14.532+0800: 27253.342: [GC concurrent-root-region-scan-start]
2022-11-23T15:33:14.540+0800: 27253.350: [GC concurrent-root-region-scan-end, 0.0077278 secs]
2022-11-23T15:33:14.540+0800: 27253.350: [GC concurrent-mark-start]
2022-11-23T15:33:16.881+0800: 27255.691: [GC concurrent-mark-end, 2.3412370 secs]
2022-11-23T15:33:16.881+0800: 27255.691: [GC remark 2022-11-23T15:33:16.881+0800: 27255.691: [Finalize Marking, 0.0001521 secs] 2022-11-23T15:33:16.882+0800: 27255.692: [GC ref-proc, 0.0006298 secs] 2022-11-23T15:33:16.882+0800: 27255.692: [Unloading, 0.0118105 secs], 0.0180534 secs]
 [Times: user=0.04 sys=0.00, real=0.02 secs] 
2022-11-23T15:33:16.900+0800: 27255.710: [GC cleanup 925M->925M(1024M), 0.0041387 secs]
 [Times: user=0.01 sys=0.00, real=0.00 secs] 
2022-11-23T15:34:15.075+0800: 27313.885: [GC pause (young) 27313.885: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 2602, predicted base time: 3.19 ms, remaining time: 96.81 ms, target pause time: 100.00 ms]
 27313.885: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 45 regions, survivors: 6 regions, predicted young region time: 7.09 ms]
 27313.885: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 45 regions, survivors: 6 regions, old: 0 regions, predicted pause time: 10.28 ms, target pause time: 100.00 ms]
 27313.895: [G1Ergonomics (Concurrent Cycles) do not request concurrent cycle initiation, reason: still doing mixed collections, occupancy: 941621248 bytes, allocation request: 0 bytes, threshold: 483183810 bytes (45.00 %), source: end of GC]
 27313.895: [G1Ergonomics (Mixed GCs) do not start mixed GCs, reason: reclaimable percentage not over threshold, candidate old regions: 8 regions, reclaimable: 2873312 bytes (0.27 %), threshold: 5.00 %]
, 0.0100596 secs]
   [Parallel Time: 8.9 ms, GC Workers: 4]
      [GC Worker Start (ms): Min: 27313885.0, Avg: 27313887.0, Max: 27313888.9, Diff: 4.0]
      [Ext Root Scanning (ms): Min: 0.0, Avg: 0.6, Max: 1.2, Diff: 1.2, Sum: 2.2]
      [Update RS (ms): Min: 0.0, Avg: 1.3, Max: 2.6, Diff: 2.6, Sum: 5.2]
         [Processed Buffers: Min: 0, Avg: 3.5, Max: 10, Diff: 10, Sum: 14]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 4.9, Avg: 5.0, Max: 5.1, Diff: 0.2, Sum: 20.1]
      [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 4.9, Avg: 6.9, Max: 8.9, Diff: 4.0, Sum: 27.6]
      [GC Worker End (ms): Min: 27313893.9, Avg: 27313893.9, Max: 27313893.9, Diff: 0.0]
   [Code Root Fixup: 0.1 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.1 ms]
   [Other: 1.0 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 0.7 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 0.0 ms]
      [Humongous Register: 0.0 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.1 ms]
   [Eden: 45.0M(45.0M)->0.0B(46.0M) Survivors: 6144.0K->5120.0K Heap: 944.1M(1024.0M)->899.8M(1024.0M)]
 [Times: user=0.03 sys=0.00, real=0.01 secs] 
2022-11-23T15:34:15.631+0800: 27314.441: [GC pause (young) 27314.441: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 4127, predicted base time: 4.55 ms, remaining time: 95.45 ms, target pause time: 100.00 ms]
 27314.441: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 46 regions, survivors: 5 regions, predicted young region time: 6.81 ms]
 27314.441: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 46 regions, survivors: 5 regions, old: 0 regions, predicted pause time: 11.36 ms, target pause time: 100.00 ms]
 27314.450: [G1Ergonomics (Concurrent Cycles) request concurrent cycle initiation, reason: occupancy higher than threshold, occupancy: 942669824 bytes, allocation request: 0 bytes, threshold: 483183810 bytes (45.00 %), source: end of GC]
, 0.0093238 secs]
   [Parallel Time: 8.6 ms, GC Workers: 4]
      [GC Worker Start (ms): Min: 27314441.0, Avg: 27314441.0, Max: 27314441.0, Diff: 0.0]
      [Ext Root Scanning (ms): Min: 0.6, Avg: 0.7, Max: 0.7, Diff: 0.1, Sum: 2.7]
      [Update RS (ms): Min: 2.3, Avg: 2.5, Max: 2.7, Diff: 0.4, Sum: 9.9]
         [Processed Buffers: Min: 3, Avg: 5.2, Max: 9, Diff: 6, Sum: 21]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 5.1, Avg: 5.3, Max: 5.5, Diff: 0.4, Sum: 21.4]
      [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 8.5, Avg: 8.5, Max: 8.5, Diff: 0.0, Sum: 34.1]
      [GC Worker End (ms): Min: 27314449.5, Avg: 27314449.5, Max: 27314449.5, Diff: 0.0]
   [Code Root Fixup: 0.1 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.0 ms]
   [Other: 0.7 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 0.3 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 0.0 ms]
      [Humongous Register: 0.0 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.1 ms]
   [Eden: 46.0M(46.0M)->0.0B(44.0M) Survivors: 5120.0K->7168.0K Heap: 945.8M(1024.0M)->903.2M(1024.0M)]
 [Times: user=0.03 sys=0.00, real=0.01 secs] 
 27374.524: [G1Ergonomics (Concurrent Cycles) request concurrent cycle initiation, reason: occupancy higher than threshold, occupancy: 942669824 bytes, allocation request: 589840 bytes, threshold: 483183810 bytes (45.00 %), source: concurrent humongous allocation]
 27374.525: [G1Ergonomics (Concurrent Cycles) request concurrent cycle initiation, reason: requested by GC cause, GC cause: G1 Humongous Allocation]
 27374.525: [G1Ergonomics (Concurrent Cycles) initiate concurrent cycle, reason: concurrent cycle initiation requested]
2022-11-23T15:35:15.715+0800: 27374.525: [GC pause (young) (initial-mark) 27374.525: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 1557, predicted base time: 3.33 ms, remaining time: 96.67 ms, target pause time: 100.00 ms]
 27374.525: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 12 regions, survivors: 7 regions, predicted young region time: 4.48 ms]
 27374.525: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 12 regions, survivors: 7 regions, old: 0 regions, predicted pause time: 7.81 ms, target pause time: 100.00 ms]
, 0.0065173 secs]
   [Parallel Time: 5.7 ms, GC Workers: 4]
      [GC Worker Start (ms): Min: 27374524.8, Avg: 27374524.8, Max: 27374524.8, Diff: 0.0]
      [Ext Root Scanning (ms): Min: 0.7, Avg: 0.8, Max: 0.8, Diff: 0.1, Sum: 3.0]
      [Update RS (ms): Min: 0.5, Avg: 0.6, Max: 0.9, Diff: 0.4, Sum: 2.5]
         [Processed Buffers: Min: 1, Avg: 2.2, Max: 5, Diff: 4, Sum: 9]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 4.0, Avg: 4.2, Max: 4.3, Diff: 0.4, Sum: 16.9]
      [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 5.6, Avg: 5.6, Max: 5.7, Diff: 0.0, Sum: 22.6]
      [GC Worker End (ms): Min: 27374530.4, Avg: 27374530.4, Max: 27374530.4, Diff: 0.0]
   [Code Root Fixup: 0.0 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.0 ms]
   [Other: 0.7 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 0.4 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 0.0 ms]
      [Humongous Register: 0.0 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.0 ms]
   [Eden: 12.0M(44.0M)->0.0B(49.0M) Survivors: 7168.0K->2048.0K Heap: 915.2M(1024.0M)->901.1M(1024.0M)]
 [Times: user=0.02 sys=0.00, real=0.00 secs]  

I use GCView to open the GC log , and I can see that as the heap usage gets higher and higher, Full GC triggers frequently

Summary、Memory、Pause

  • The process runs for 8+h.
  • The maximum utilization rate of the heap reaches 100%.

  • The maximum usage rate of the old generation reaches 105.2%.
  • The maximum utilization rate of the new generation reaches 100%.

This tool is only a basic analysis of memory, and does not have detailed large object information, so I found this tool Memory Analyzer Mat again. Memory Analyzer Mat JVM Analysis

Thanks for likes and attention!

Guess you like

Origin blog.csdn.net/qq_35995514/article/details/130207816