Simple use of Visual VM as a JVM graphical tool

Find the method that takes the most CPU time

Example 1:
insert image description here
Example 2:
insert image description here
insert image description here

Analyze heap dump

insert image description here
insert image description here
insert image description here

Compare two heap dump files

import java.util.ArrayList;
import java.util.Random;
/**
 * -Xms30m -Xmx30m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps
 */
public class OOMTest {
    
    
    public static void main(String[] args) throws InterruptedException {
    
    
        ArrayList<Box> list = new ArrayList<>();
        while(true){
    
    
            Thread.sleep(20);
            list.add(new Box(new Random().nextInt(1024 * 56)));
        }
    }
}

class Box{
    
    
    private byte[] data;

    public Box(int length) {
    
    
        this.data = new byte[length];
    }
}

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/fengsheng5210/article/details/123713758