当前位置:网站首页>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
边栏推荐
- C#訪問SQL Server數據庫兩種方式的比較(SqlDataReader vs SqlDataAdapter)
- MIME类型大全
- mysql基础入门 day3 动力节点[老杜]课堂笔记
- 2021-05-17
- C#访问MongoDB并执行CRUD操作
- 【NVMe2.0b 14-1】Abort、Asynchronous Event Request、Capacity Management command
- Is the reverse repurchase of treasury bonds absolutely safe? How to open an account online
- [untitled]
- Game 280 problem2: minimum operands to turn an array into an alternating array
- Detectron2 source code reading 2--- using the configurable decorator to build the dataloader
猜你喜欢
随机推荐
一次cpu 跌底排查
Detectron2 source code reading 2--- using the configurable decorator to build the dataloader
CUDA implements matrix replication
Oracle expansion table space installed in docker
云服务器上部署仿牛客网项目
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
VIM from dislike to dependence (21) -- cross file search
Is the reverse repurchase of treasury bonds absolutely safe? How to open an account online
Detailed explanation of pytoch's scatter function
Be careful of this hole in transmittable thread local
Interference source current spectrum test of current probe
Wikimedia Foundation announces the first customers of its new commercial product "Wikimedia enterprise"
Detectron2 source code reading 3-- encapsulating dataset with mapper
示波器探头对测量电容负荷有影响吗?
Viteproject require Syntax Compatibility Problem Solving require is not defined
Flink Exception -- No ExecutorFactory found to execute the application
挖财开户安全吗?怎么有人说不靠谱。
2021-02-27
El input limit can only input numbers
Rendering engine development
![[nvme2.0b 14-7] set features (Part 1)](/img/0d/c26ae2475ae69291d83b4096ea942b.png)






![[untitled]](/img/45/368c41a74bf0738369c58c5963fca0.jpg)

