Get the App
SLTechnology News&Howtos  ›  Development  › 

How to troubleshoot Java programs that occupy a high level of CPU under Linux

Shulou Source: shulou.com Published: 2022-06-01 20:52:22 10月04日 Update

This article mainly shows you "how to troubleshoot Java programs that occupy a high CPU under Linux", which is easy to understand and clear, hoping to help you solve your doubts. Let the editor lead you to study and learn this article "how to troubleshoot Java programs that occupy a high CPU under Linux".

Jstack is a stack trace tool that comes with the java virtual machine. Jstack is used to print out the Java stack information for a given java process ID or core file or remote debugging service.

Deliberately set up a scene with a high CPU footprint:

To troubleshoot the problem, steps:

\ 1. Ps-mp [replace with process ID PID]-o THREAD,tid,time

It is found that threads 6322 and 6323 take up a high amount of CPU and take a long time.

\ 2. Printf "% x" [thread ID TID]

Convert TID to hexadecimal.

\ 3. Jstack [process ID PID] | grep [thread ID hexadecimal]-A 10-B 10

Using the jstack tool, look at the front and back 10 lines to find the problem!

Intentionally set in the code:

\ 4. Repeat 2 and 3 to see another thread.

--

Appendix: to access your own Virtual Box, the network settings should be adjusted to:

The above is all the contents of this article entitled "how to troubleshoot Java programs that occupy high CPU under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Threads programs content articles processes stacks tools questions learning help code information hexadecimal scenarios location time understandability more organization steps Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB NVidia Shulou Tech Info Docker