Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
introduction
Java programs often have problems with high CPU usage in the actual production process, the reason how to troubleshoot it, we probably describe troubleshooting methods.
First, the CPU-intensive investigation process
Use top
the command, press the P button or press shift + P keys will be carried out in the capital opened in the capital did not open the case in accordance with the level of CPU usage sort, search process to obtain maximum utilization of process PID.
Second, find the actual occupation of the highest CPU thread
Use the command top -H -p PID
, where PID is the last step acquisition process PID, by this command to view the highest thread CPU ID actually occupied, where several TID
Third, access to thread stack information corresponding thread
- Use the command
printf "%x\n" tid
to convert hex thread ID - Use the command
jstack pid |grep tid -A 50
, here tid 16 hexadecimal conversion after the previous step, use this command to view information corresponding to a thread stack of the thread, to be analyzed from the corresponding code based on the thread stack.