当前位置:网站首页>CPU surge problem location

CPU surge problem location

2022-06-09 03:43:00 seven billion two hundred and fifty-eight million two hundred a

CPU Soaring problem positioning

happen CPU The situation of soaring can be jstack Command positioning problem ,jstack + pid Look for deadlocks .
Test code

package com.aword.demo.jvm;
public class CPUDemo {
    public int compute() {
        int a = 1;
        int b = 2;
        int c = (a + b) * 10;
        return c;
    }
    public static void main(String[] args) {
        CPUDemo cpuDemo = new CPUDemo();
        while (true) {
            cpuDemo.compute();
        }
    }
}

Compile the class to CPUDemo.class Put the file in the local virtual machine
Carry out orders java com.aword.demo.jvm.CPUDemo
Start to check the progress

top

 Insert picture description here
Check the memory of the process

top -p pid

 Insert picture description here
Press H , Get the details of each thread .
 Insert picture description here
find CPU The highest thread occupied tid, To 16 Base number .

printf %x tid

 Insert picture description here
perform jstack Get the thread stack information after the line 10 That's ok , You can see from the stack what causes cpu Skyrocketing call method .

jstack pid | grep -A 10  Hexadecimal tid

 Insert picture description here
Check the corresponding stack information to find out the code that may have problems

This article is for study and exchange only , Deletion of infringement contact .

原网站

版权声明
本文为[seven billion two hundred and fifty-eight million two hundred a]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090326163349.html