Analysis and positioning of high CPU usage

Use Linux commands and JDK commands to check together

First, first use the top command to find the CPU with the highest proportion

Second, ps -ef or jps is further positioned to learn how to use which background program is constantly occupying the CPU

Both commands find out that the process number is 5101

Third, locate a specific thread or code

Command: ps -mp process -o THREAD, tid, time

Parameter explanation:

-m show all threads

-p pid The time the process uses the cpu

-o This parameter is a user-defined format

It is further located that there is a problem with the 5102 thread.

The fourth step is to convert the required thread ID to hexadecimal format (English lowercase format)

Because the thread runs in the memory in hexadecimal

Format: printf "%x\n" the thread ID in question

The hexadecimal number of 5102 is 13ee.

The fifth step, jstack process ID | grep tid (hexadecimal thread ID lowercase English) -A60

At this time, it is located that there is a problem with the 10th line of code in the class com.atguigu.test.JavaDemo02. 

Guess you like

Origin blog.csdn.net/kidchildcsdn/article/details/114212823