Get the App
SLTechnology News&Howtos  ›  Development  › 

How to troubleshoot the high CPU caused by Java application

Shulou Source: shulou.com Published: 2022-06-03 16:51:11 11月14日 Update

This article mainly introduces how to troubleshoot too high CPU caused by Java application, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

Use the top command to query the service cpu usage

Server resource utilization

You can see that 31737 of this process has a huge CPU utilization.

Use top-Hp 31737 to query the resource utilization of each thread in the 31737 process

Top-Hp 31737

Use top-Hp 31737 to query the resource utilization of each thread in the 31737 process

31737 Utilization of individual threads in the process

Because the screenshot was lost at that time, to put it simply, using the top-Hp 31737 command to query the 31737 process, a thread id for 5322 takes up too much CPU

Use printf "% x\ n" 5322 to convert thread id to hexadecimal

Printf "% x\ n" 5322

Because the local thread identifies the nid as hexadecimal when printing the thread stack, use this command to convert the thread id to hexadecimal

The hexadecimal of 5322 is 14ca

Use the jstack command to print stack information

Jstack 31737 | grep-10 14ca

Use jstack 31737 | grep-10 14ca to print stack information for 31737 and look for thread stack information identified as 14ca by the local thread

31737 stack information

As shown in the figure, the status of the thread is TIMED_WAITING, and the object is waiting. Check the source code.

The code that has a problem

The cause of the problem will not be analyzed in detail. The main purpose here is to share the process of troubleshooting.

Du Niang, there is a big god answer is right, connected here, interested can take a look at the https://stackoverflow.com/questions/6981564/why-must-the-jdbc-driver-be-put-in-tomcat-home-lib-folder/7198049#7198049

The above is all the contents of this article entitled "how to troubleshoot too high CPU due to Java applications". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Threads usage processes information hexadecimal commands stacks queries resources questions applications interests content logos articles services good huge code value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Redmi Docker Linux Shulou Tech Info