A thread dump is fairly quick to generate: it's a list of the VM's threads, with their status and the trace
they are running on.
The format of the thread dump may differ depending on the method used to obtain it.
console method:
The
"jstack" utility is located in the "/bin" directory of your JDK.
Use an
jstack -l [PID_DU_PROCESS_JAVA] > [FILENAME.tdump]
If the process doesn't respond, you can try:
jstack -F -l [PID_DU_PROCESS_JAVA] > [FILENAME.tdump]
(be careful not to use the -m
option unless you need to)
By executing this command several times, thread-dumps are accumulated in the same file and the evolution of threads can easily be analyzed.
On Windows, if you get an error message: "Insufficient memory or insufficient privileges to attach" or "Not enough storage is available to process this command". You can use the command
psexec
to run jstack with the system account (option -s):
psexec -s "%JAVA_HOME%\bin\jstack.exe" PID > stack.txt
Graphical method (preferred):
If you can connect with jvivualvm
, you can generate the thread dump directly via the context menu:
it's often a good idea to run 2 thread dumps at intervals of a few tens of seconds, to allow you to analyze the evolution of threads.