-
Notifications
You must be signed in to change notification settings - Fork 180
Taking and interpreting a JVM thread dump
Ricardo Mateus edited this page Nov 7, 2022
·
6 revisions
Ever wanted to know what's going on exactly in the JVM, when a debugger is not available (eg. at a customer?)
A thread dump will provide an instant snapshot of all stacks, in all threads. Sometimes that is sufficient.
zypper in java-11-openjdk-devel
# Tomcat
jstack `ps aux | grep catalina.startup | grep -v grep | awk '{print $2}'`
# Taskomatic
jstack `ps aux | grep TaskomaticDaemon | grep -v grep | awk '{print $2}'`
The following Bash script can be used to obtain Tomcat dumps every 5 seconds:
#!/bin/bash
mkdir /tmp/tomcat_thread_dump_monitor
while :
do
jstack `ps aux | grep catalina.startup | grep -v grep | awk '{print $2}'` > /tmp/tomcat_thread_dump_monitor/`date --iso-8601=seconds`-dump.txt
sleep 5
done
One option can be intellij, which has a great feature for it.
On intellij menu, go to Code
-> Analyze Stack Trace or Thread Dump
. This will open a window where one can past the thread dump data.
If one does this with suma project opened in a branch with the same version where the thread dump was taken, it will provide links to classes inside the project.