The problem of viewing a thread under linux

Background:

After running the test program, the top command found that a certain process (pid) took up 100% of the CPU.

Check which thread occupies the most resources:

ps mp pid -o THREAD,tid, command to check the occupancy of all threads under this process.



Thread 324 was found to be the most occupied.

Use jstack to track:

jstack pid to view the output to the temporary file

jstack 323 > test

Convert the thread id (324) that has just found the most CPU occupied to hexadecimal, 324=="144

View the file generated by jstack:



as can be seen below Which line of code caused it? Check that line of code and find that there is an infinite loop. Tracking is resolved.

The above is to check the CPU usage, and other related resource analysis methods should be similar.

This kind of finding a problem is very fulfilling, and everyone can use it after learning a trick from our Niu Niu development. ~~~


Postscript:
There are many things that the test focuses on, point to point, and then point to point, and the developers are in Technically, there are many analysis methods. After finding bugs, we don’t directly throw them to the development, and after fixing the peripheral regression, we ask the development for analysis methods, and get “fishing”. The development is also very happy to teach us, so that we will encounter You can directly analyze similar problems, so that you can continuously improve yourself, improve efficiency, and have a great sense of accomplishment. This is a very happy thing.

from: https://my.oschina.net/jccpp/blog/129784

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326691208&siteId=291194637
Recommended