当前位置:网站首页>CPU over high diagnosis and troubleshooting

CPU over high diagnosis and troubleshooting

2022-06-25 15:24:00 Running pig ZC

1: Code preparation

Loop printing random numbers

public class TestCPUHigh {
    

    public static void main(String[] args) {
    

        while (true){
    
            System.out.println(new java.util.Random().nextInt(66669999));
        }
    }
}

2: The phenomenon

pid = 5783 The process of is very expensive

top1

3: The diagnosis

3.1:top
3.2: Locate the process jps

jps

3.3: Go to code

Specific threads pid 5783

ps -mp 5783-o THREAD,tid,time

t

3.4: Hexadecimal conversion

Threads id Switch to 16 Base number ( Letter lowercase , If there are letters ) The thread in the figure takes a long time TID=5784 convert to 16 Base number 1698

3.5:jstack location

jstack 5783 | grep 1698 -A60

View stack information 60 That's ok

ay

3.6: Find familiar classes

Find the class from your project find TestCPUHigh.java Of the 6 That's ok , Diagnosis complete

原网站

版权声明
本文为[Running pig ZC]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200503403927.html