当前位置:网站首页>How to monitor JVM GC
How to monitor JVM GC
2022-06-09 05:43:00 【Die hard audio and video】
How to monitor GC
gc Monitoring is GC Necessary prerequisites for tuning , Only monitoring data , To know whether or not GC tuning ? How to tune ? Is tuning effective ?
There are many ways to monitor GC, The difference is only the form of presentation , So you don't have to learn all the monitoring gc Methods .
jstat
jstat yes HotSpot JVM Provides a monitoring tool ,jstat Not only provide GC Operational information , It also provides information about class loading operations and runtime compiler operations .
jstat Be placed in $JDK_HOME/bin. So long as java and javac Can execute ,jstat The same can be done .
You can execute the following statements in a command line environment .
jps Acquisition process id
jps
jstat -gc 28352 1000
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
122048.0 124224.0 0.0 1945.4 1452288.0 537235.5 490368.0 163970.8 - - - - 33 1.843 2 0.697 2.541
122048.0 124224.0 0.0 1945.4 1452288.0 537235.5 490368.0 163970.8 - - - - 33 1.843 2 0.697 2.541
122048.0 124224.0 0.0 1945.4 1452288.0 537235.5 490368.0 163970.8 - - - - 33 1.843 2 0.697 2.541
122048.0 124224.0 0.0 1945.4 1452288.0 537235.5 490368.0 163970.8 - - - - 33 1.843 2 0.697 2.541
122048.0 124224.0 0.0 1945.4 1452288.0 537235.5 490368.0 163970.8 - - - - 33 1.843 2 0.697 2.541
Want to get GC Performance related data needs to be continuously monitored , So in execution jstat when , Output regularly GC Monitoring information .
perform jstat –gc 1000 ( or 1s) Will show every second GC Monitoring data .jstat –gc 1000 10 Every time 1 Every second , And altogether 10 Time .
have access to jstat -options To see other options , Different jdk Versions may vary .
| Options | describe |
|---|---|
| gc | Shows the current size of each heap area and its current usage (Ede、survivor、old etc. )、 Executive GC Total and GC Cumulative time of operation |
| gccapactiy | Shows the minimum size of each heap area (ms) And maximum size (mx)、 Current size and execution of each region GC frequency .( No display GC Current usage and cumulative time of the operation |
| gccause | It shows -gcutil Information provided The last time GC The reason and current GC Why . |
| gcnew | Show the space of the younger generation GC The performance data |
| gcnewcapacity | Show statistics on the size of the younger generation space |
| gcold | The output of the elderly generation space GC The performance data |
| gcoldcapacity | Output the size statistics of the older generation space |
| gcpermcapacity | Output the size statistics of the permanent generation space |
| gcutil | Output the usage percentage of each heap area , as well as gc Total number of executions and GC Cumulative time of operation |
The most used command ,gcutil,gc,gccapacity
- gcutil Used to check the usage of the heap area 、 Executive GC Times and GC Total cumulative time of operation
- gccapacity Option and other options can be used to check the actual size of the allocation .
- gc Used to view the current in real time gc situation
Output column information




summary :jstat The benefits of , You can use it as long as you have a console .
When using –gcutil Will output the following information . stay GC When optimizing , You need to pay special attention to YGC, YGCT, FGC, FGCT and GCT.
S0 S1 E O P YGC YGCT FGC FGCT GCT
0.00 66.44 54.12 10.58 86.63 217 0.928 2 0.067 0.995
0.00 66.44 54.12 10.58 86.63 217 0.928 2 0.067 0.995
0.00 66.44 54.12 10.58 86.63 217 0.928 2 0.067 0.995
In this case ,YGC( The younger generation gc The total number of times ) yes 217 and YGCT( The younger generation gc Total time ) yes 0.928, So after simply averaging the data (0.928/217=0.004 second ), You can see that every new generation GC Probably need 4ms(0.004 second ), and full GC The average time of is 33ms.
But that doesn't tell the story , The average data cannot be analyzed to determine each time gc Time spent , such as full gc Total time 70ms, altogether gc two , One of them was 10ms, And the other might be 60ms, So in order to be more accurate gc problem , have access to -verbosegc.
-verbosegc
-verbosegc It's starting a Java Can be specified when applying JVM Parameters ,jstat You can do this without specifying any jvm Parameter .
Here is -verbosegc The available parameters of
- -XX:+PrintGCDetails
- -XX:+PrintGCTimeStamps
- -XX:+PrintHeapAtGC
- -XX:+PrintGCDateStamps (from JDK 6 update 4)
jdk1.6 Example
java -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:./gc.log -jar test.jar
YoungGC The log is explained as follows :

FullGC The log is explained as follows

springboot actuator Report points + prometheus collect + grafana Graphic display
1. be based on springboot Business reporting points gradle To configure :
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'io.micrometer:micrometer-registry-prometheus'
2. To configure yml
management:
endpoints:
web:
exposure:
include: health,prometheus
Default point reporting url:
http://ip:port/actuator/prometheus
3. install promethues
4. install grafana, Import Spring Boot 2.1 Statistics Templates
Memory leak - Young generation eden Characteristics of the zone :

Memory leak - Characteristics of old age :

Memory leak - Young generation survivor Characteristics of the zone :

Memory leak -gc Stop The World diagram :

summary
In general use jstat To monitor gc, If you feel gc There is a problem , have access to verbosegc Parameters . If you use springboot, have access to springboot actuator Report points + prometheus collect + grafana Graphic display programme .
边栏推荐
- An article takes you to know what token is
- Ffmpeg pulls webrtc streams, and the first all open source solution in the metartc industry is coming
- C language to write a small program for computing file CRC
- Alibaba cloud AI training camp -sql foundation 2: query and sorting
- In latex, \cdots is followed by a sentence. What's wrong with the format of the following sentence.
- Alibaba cloud AI training camp - SQL basics 4: set operation - addition and subtraction of tables, join, etc
- 冒泡排序,打印菱形,打印直角三角形,打印倒三角,打印等边三角形,打印九九乘法表
- Gradient accumulation setting for pytorch DDP acceleration
- matlab----多项式、函数
- Yolov5-6.0 series | yolov5 model network construction
猜你喜欢

Locating memory problems using mat

In 2022, the database audit manufacturer will choose cloud housekeeper! Powerful!

Several implementation methods of redis distributed lock

Practical guide to GStreamer application development (II)

和琪宝的重庆之旅~

【IT】福昕pdf保持工具選擇

synchronized 详细解析

【IT】福昕pdf保持工具选择
![[it] Foxit PDF retention tool selection](/img/1e/87dbd435e830c139bc3d5cf86d6d57.png)
[it] Foxit PDF retention tool selection

arthas-boot
随机推荐
Web page capture software
Morsel driven parallelism: a NUMA aware parallel query execution framework
Ffmpeg pulls webrtc streams, and the first all open source solution in the metartc industry is coming
Tricks | [trick6] learning rate adjustment strategy of yolov5 (one cycle policy, cosine annealing, etc.)
Alibaba cloud AI training camp -sql basics 6: test questions
三大队列cxq,entrylist,waitset 个人理解分析
Swift 扩展
Yolov5-6.0系列 | yolov5的模型网络构建
[it] Foxit PDF retention tool selection
输入两个正整数m和n,求其最大公约数和最小公倍数。
Gradient accumulation setting for pytorch DDP acceleration
matlab----多项式、函数
csv文件读取(v3&v5)
seaweedfs-client适配高版本的seaweedfs服务
计网中的一些概念
Fundamentals of deep learning: face based common expression recognition (2) - data acquisition and collation
Stack
Analysis of countdownlatch source code of AQS
Bubble sort, print diamond, print right triangle, print inverted triangle, print equilateral triangle, print 99 multiplication table
Interview process and thread