当前位置:网站首页>JVM tuning related commands and explanations
JVM tuning related commands and explanations
2022-06-30 08:38:00 【Attacking brother pea】
Reference to the original :https://www.zhihu.com/question/427461208/answer/2537026920
List of articles
jinfo
You can print some current jvm All kinds of parameters , such as jvm Some parameters to start ,jvm Some properties in k-v etc. , Can pass jinfo --help View specific commands .
jmap( Memory overflow solution )
This parameter allows you to view JVM Some related data in memory ;
adopt jps obtain java Process PID, adopt jmap Analyze the present java Memory data of the process , Common commands :
- 1. Heap history :
jmap -histo[:live] <pid> [ > ./xx.log]: You can see the current JVM The number of objects created by all loaded classes in , Occupy memory, etc , You can import files to view ; - 2. Heap information :
jmap -heap <pid>: You can see java The proportion of the new generation and the old generation of the program is the usage . - 3. Pile up dump
jmap -dump:format=b,file=xx.hprof <pid>: Sure dump Heap log , See and jmap similar , have access to visualVM see .
adopt jmap You can view the heap usage , For example, locating simple memory leaks , adopt 1,3 You can see that there are many objects of those classes .
You can set parameters to control the recording when a memory overflow occurs xx.hprof journal , This can be used to analyze memory leaks .-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=xxx/xxx/xx.hprof
jstack(cpu High occupancy solutions )
This command can view the stack information of the thread ,jstack You can locate a simple deadlock , The most common way is through jstack location CPU High problem , The specific steps are :
- 1.
topCommand to view the current occupancy cpu Highest process pid; - 2.
top -p <pid>View high memory consumption cpu The process of , Press H To get the occupation in the current process cpu The highest thread of tid; - 3.
jstack <pid> | grep -A10 <16 Base number tid>View the specific class information that the thread that occupies the highest thread is executing . Be careful :tid Of 16 Lower case base .
Through this process, you can directly locate which thread is executing, which takes a lot of cpu, Including which class to execute , Very convenient , This interview often asks .
jstat(FullGC Frequent solutions )
This command can view the detailed usage of various parts of the heap , Can pass jstat --help view help ;
The most common command jstat -gc <pid> [1000 10] Show view gc situation , Every time 1 Print once per second, a total of 10 Time ( Optional ), You can view the total size and size of each belt , The key can also be seen youngGC, and FullGC Respective total times , Total time spent and time spent together , about jvm The optimization of is to optimize it FullGC frequency ,FullGC The less, the better. , It's better to control FullGC Once every few hours or even days , It depends on the business situation .
FullGC Analyze the process frequently :
FullGC We can't directly guess why , It needs some analysis , To determine what caused it , Generally, we need to use the above command to regularly observe the heap .
- 1. Observe Eden The object of the zone grows , For example, how many objects are created per second ;
- 2. happen youngGC The interval time and time consumption of each time , Every time youngGC How many objects enter the new generation and how many enter the old generation ;
- 3. Trigger fullGC Time interval and time consuming , Every time FullGC How much space will be released .
Build the model :
How many threads in the system will generate per second M The object of ==> ① Get into Eden;② Big target into the old generation ? ==> n The second is full Eden District ==> Conduct youngGC ==> ① Number of objects entering the elderly generation ( The reasons causing , Dynamic age determination mechanism ? Age threshold reached ?) ==> FullGC Number of objects remaining after
To analyze problems :
Trigger FullGC The reason is that the old generation can't fit any more , So we need to see why we put objects frequently in the old age ...
- 1. to JVM The allocated heap memory is too small , Can't meet the requirements , In the old days, every time GC Only a small amount of space can be released , You can increase the size of the heap .
- 2. Large object setting threshold is too small , A temporary large object may be generated in the system , For example, a lot of data is loaded into memory at one time , You can modify the threshold, but it's best to optimize the code .
- 3. The judgment mechanism of dynamic age leads to too many objects entering the elderly generation , If we judge that a large number of business objects are living and dying, we can appropriately increase the proportion of the new generation and the old generation , Avoid dynamic age determination, which leads to many garbage objects entering the elderly generation .
- 4. The old space guarantee mechanism may lead to every youngerGC It's going to be done before FullGC, Whether the space guarantee mechanism has been opened , If it is not turned on and a large number of objects are generated each time, it will result in one or several times youngGC To carry out FullGC
边栏推荐
- 挖财开户安全吗?怎么有人说不靠谱。
- Introduction to MySQL foundation power node [Lao Du] class assignment
- [untitled]
- 127.0.0.1、0.0.0.0和localhost
- Redis设计与实现(八)| 事务
- Occasionally, Flink data is overstocked, resulting in checkpoint failure
- Enhance the add / delete operation of for loop & iterator delete collection elements
- 电流探头电路分析
- Redis设计与实现(七)| 发布 & 订阅
- 一次cpu 跌底排查
猜你喜欢

Swagger use

【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command

Enhance the add / delete operation of for loop & iterator delete collection elements

Qt连接神通数据库

Redis设计与实现(一)| 数据结构 & 对象

【kotlin 协程】万字协程 一篇完成kotlin 协程进阶

【NVMe2.0b 14-5】Firmware Download/Commit command

Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush

1. Problems related to OpenGL window and environment configuration

Pytorch BERT
随机推荐
Redis design and Implementation (VI) | cluster (sharding)
Understanding society at the age of 14 - reading notes on "happiness at work"
CUDA realizes L2 European distance
2021-05-17
证券开户的优惠怎样才能得到?在线开户安全?
维基媒体基金会公布新商业产品“维基媒体企业”首批客户
This point in JS
Detectron2 source code reading 3-- encapsulating dataset with mapper
涂鸦Wi-Fi&BLE SoC开发幻彩灯带
TiDB v6.0.0 (DMR) :缓存表初试丨TiDB Book Rush
Redis design and Implementation (IV) | master-slave replication
Introduction to MySQL foundation power node [Lao Du] class assignment
2021-05-06
基于Svelte3.x桌面端UI组件库Svelte UI
Qqquickpainteditem implements graffiti program drawing board
【NVMe2.0b 14-2】Create/Delete Queue
增强for循环的增删操作 & 迭代器删除集合元素
Axure制作菜单栏效果
JVM调优相关命令以及解释
[untitled]