当前位置:网站首页>GC log analysis

GC log analysis

2022-06-09 03:43:00 seven billion two hundred and fifty-eight million two hundred a

One 、 Log printing

1.JVM Add a parameter in

‐Xloggc:./gc‐%t.log ‐XX:+PrintGCDetails ‐XX:+PrintGCDateStamps ‐XX:+PrintGCTimeStamps ‐XX:+PrintGCCause ‐XX:+UseGCLogFileRotation ‐XX:NumberOfGCLogFiles=10 ‐XX:GCLogFileSize=100M

2.Tomcat Add to JAVA_OPTS variable

Two 、GC Log analysis Demo

A local service , The parameters are as follows :

java -jar -Xloggc:./gc-%t.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCCause -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M .\microservice-eureka-server.jar

 Insert picture description here

Project start , open the log file , The contents are as follows :
Configuration parameters of the project
Not only is printing configured here GC journal , And related VM Memory parameters .
 Insert picture description here
GC Situation analysis
 Insert picture description here

2022-06-04T14:42:00.589+0800: 2.829: [Full GC (Metadata GC Threshold) [PSYoungGen: 4997K->0K(129024K)] [ParOldGen: 2890K->7520K(94720K)] 7887K->7520K(223744K), [Metaspace: 20864K->20864K(1069056K)], 0.0381591 secs][Times: user=0.16 sys=0.00, real=0.04 secs] 

1、2.829 : from jvm Start the calculation to this time GC Time passed
2、Full GC(Metadata GC Threshold): This is a time full gc, In brackets is gc Why , PSYoungGen It's the younger generation GC, ParOldGen It's from the old days GC,Metaspace It's the of meta space GC.
3、[PSYoungGen: 4997K->0K(129024K)] : The three numbers correspond to GC It used to occupy the size of the younger generation ,GC Later, the younger generation occupied , And the whole young generation Small .
4、[ParOldGen: 2890K->7520K(94720K)] : The three numbers correspond to GC It used to occupy the size of the old age ,GC Later, the old age occupied , And the size of the whole old age .
5、7887K->7520K(223744K): The three numbers correspond to GC The size of the heap memory previously occupied ,GC After that, the heap memory is occupied , And the entire heap memory Size .
6、[Metaspace: 20864K->20864K(1069056K)]: The three numbers correspond to GC The size of the memory that used to occupy meta space ,GC After that, the meta space memory is occupied , With And the size of the entire Metaspace memory .
7、0.0381591 secs: This point in time GC It takes time

Optimize
From the log, you can find fullgc It is caused by insufficient meta space , So we can turn up the meta space .

java -jar -Xloggc:./gc‐adjust-%t.log ‐XX:MetaspaceSize=256M ‐XX:MaxMetaspaceSize=256M -XX:+PrintGCDetails -XX:+PrintGCDateStamps ‐XX:+PrintGCTimeStamps -XX:+PrintGCCause -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M .\microservice-eureka-server.jar

Let's take a look after the adjustment gc The log finds that there are no problems caused by insufficient meta space fullgc 了

3、 ... and 、gceasy visualization GC journal

Upload gc The file uses a visual interface to show GC situation
Official website address :https://gceasy.io/
Put the GC Log file import analysis
1、 You can see the younger generation 、 Old age 、 And the memory allocation and maximum usage of the permanent generation .
 Insert picture description here
2、 You can see that there is GC Before and after changes and other information
 Insert picture description here

Four 、JVM Parameter summary view command

Print out the default values of all parameter options

java -XX:+PrintFlagsInitial

Print out the values of all parameter options that take effect when the program is run

java -XX:+PrintFlagsFinal

This article is for study and exchange only , Deletion of infringement contact .

原网站

版权声明
本文为[seven billion two hundred and fifty-eight million two hundred a]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090326163004.html