One of the basic commands of jvm to troubleshoot memory leaks

1. Introduction to basic command functions

1. jps: View the local java process information.

2. jstack: Print thread stack information and make thread dump file.

3. jmap: print memory map, make heap dump file

4. jstat: performance monitoring tool

5. jhat: memory analysis tool

6. jconsole: a simple visual console

7. jvisualvm: a powerful console

2. Check the JVM memory leak process

(1) Find the process ID of the program to be checked

Use jps:jps -l

Use ps:ps aux | grep tomat

(2) Preliminary view of various operating status information of the virtual machine

jstat -gcutil pid

Interpretation of the results: the new generation Eden area (E, for Eden), two Survivor areas (S0, S1, for Survivor0, Survivor1), and the old age (O, for Old). Since the program was run, there have been Minor GC (YGC, meaning Young GC) times, the total time, the number of Full GC (FGC, meaning Full GC), the total time of Full GC, and the total time (GCT, meaning GC Time).

(3) Print online to view heap dump snapshot

jmap -histo:live pid

(4) Write the dump of the entire heap information to a file, here is a demonstration of the generated file name heap001.jps

jmap -dump:live,format=b,file=heap001.jps pid

(5) Analyze the dumped files, which code fragments occupy a larger amount of memory, generally because there are leaks in this section.

 

Guess you like

Origin blog.csdn.net/Mint6/article/details/105018832