jvm monitoring tool (check memory overflow and memory leak)

Visual VM can monitor the running status of jvm in real time

Press Perform GC will immediately perform a GC
press Heap Dump will generate a memory information report
Insert picture description here
You can also monitor SQL
Insert picture description here

Use visualVM to troubleshoot memory leaks

Simulate memory overflow:

import java.util.ArrayList;
public class OOM {
    
    
    public static void main(String[] args) {
    
    
        ArrayList<Integer> list = new ArrayList<>();
        int i = 0;
        while (true) {
    
    
            list.add(i++);
        }
    }
}

Insert picture description here
Insert picture description here
Open the hprof file using visual VM and
Insert picture description here
found that Integer occupies 97.9% of the memory.

Jmap view memory information or memory details under dump

Insert picture description here
Insert picture description here
You can use visual VM to view this file, generally this approach is used when Linux has no graphical interface.

Other troubleshooting tools:

jconsole java monitoring and management console

Insert picture description here
Insert picture description here
jconsole actually contains all the following instructions, but if you need to use the following instructions on a Linux system without an interface


jps view the currently running java program

Insert picture description here

jstat -gcutil pid interval time (milliseconds)

Unit: Percentage of memory
Insert picture description here
s0: survivor0 area, s1: survivor1 area, E: eden area, O: old area, M: meta space, CSS: compression type
YGC: youngGC times, YGCT: youngGC time, FGC: FullGC times, FGCT: FullGC time
GCT: GC time average time

jstack -pid is used to analyze threads

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_41699562/article/details/104313655