Using commands to view JVM information under Linux

In addition to writing business code, especially after the project goes online, Java programmers need to pay more attention to the performance of the system. At this time, they need to understand the performance of the JVM. With the help of some analysis tools of Java virtual machine, there are mainly three common commands.

1. jmap

&Nbsp; & nbsp; this command is used to view the heap dump of the JVM process in the current system, including the number of objects and the memory occupied by the objects

&Nbsp; & nbsp; usage: use JPS to view the process ID first

Use jmap – dump: live, file = 22467 to generate a Java heap dump snapshot of the live process

&Nbsp; use jmap heap PID to generate Java heap details

&Nbsp; & nbsp; use jmap-histo PID to generate information about the objects in the Java heap, including the number and space occupied

2. jstat

&Nbsp; & nbsp; is mainly used to monitor heap size and JVM garbage collection, especially GC. If full GC occurs in the elderly, it is likely to cause memory leak

We can see the percentage of space use on the new generation of survivor S0, survivor S1 heap, the percentage of space use on the new generation of Eden in the heap, the percentage of old space use on the old generation of the old generation, the percentage of memory use, the statistical times of the new generation of Yong GC, the time spent on the new generation of GC, the times spent on the full GC, the time spent, and the total GC time of the current process. Here we should pay attention to one point, Full GC is very representative. The number and time indexes of full GC can show the system performance problems. These two indexes are very large, which largely shows that there are problems in the program and the garbage can not be recycled

3. jstack

&Nbsp; & nbsp; first, use top to view the processes that consume more CPU in the system, then use top-p P id-h to view the threads that consume more CPU in the current process, get the thread PID that consumes more CPU, first convert it to hex, and finally use jstack PID | grep hex thread ID

Jstack PID can be used to analyze the process


电子邮件地址不会被公开。 必填项已用*标注