How to get a complete stack trace of a running java program that is taking 100% cpu?

56,782

Solution 1

Try with jstack. It'll give you a full list of what your threads are doing. All it needs is the process pid.

Solution 2

Take a thread dump. Connect through Visual VM and request a dump. Or if on unix then kill -3 pid or on windows Ctrl+Break on the process console would do it for you. The dump goes straight to the console. You can also use jstack to throw a dump.

Solution 3

Ctrl+\ on linux (which sends SIGQUIT)

Ctrl+Break on windows (which sends SIGBREAK under MSVCRT)

Solution 4

In *nix, with top by pressing H you can see the threads.

Then with jps you can see the pid bear in mind that if the process was started with privileges then you must execute it with sudo for instance.

If you take the thread id and converted it to hexadecimal then you can cross that data with the jstack pid output.

Both tools are in $JAVA_HOME/bin.

Solution 5

Take a look at VisualVM. There is a lot of nice profiling tools with it, and you can perform a thread dump.

Share:
56,782
sorin
Author by

sorin

Another geek still trying to decipher the meaning of “42”. It seems that amount his main interest are: online communities of practice and the way they evolve in time product design, simplicity in design and accessibility productivity and the way the IT solutions are impacting it

Updated on March 24, 2020

Comments

  • sorin
    sorin about 4 years

    I do have a jenkins instance that is stuck in some kind of endless loop without any visible activity.

    I can get the pid of the running process so how do I generate a trace that I can use for a bug report?

    I'm running on linux.