Skip to content

02. Request Thread Dumps

Ingo Rockel edited this page Nov 16, 2017 · 1 revision

There are different methods to request a thread dump from a running applications, either using a kill Signal on UNIX, using a little tool on windows, since Java 1.5 using jstack or via Java Management Extensions (JMX).

Using a kill-Signal

For requesting a thread dump, you need to send a kill-QUIT-Signal to the Java VM. For this you the PID of the VM is required and then do a kill -QUIT <PID> in a Unix Environment. On Windows there is a special tool for accomplishing this, e.g. SendSignal. See the References for a link to the homepage of this tool. It does the same like kill -QUIT on Unix. Note though, if you're using the remote connection on windows, you need to start the connection with mstsc.exe /console otherwise you won't have sufficient rights to use the tool.

The JDK will write the thread-dump to standard-out. E.g. if your application is running in a tomcat, this would be catalina.out in a default tomcat installation. In other situations this might just be the console where the application was started from.

Using Java Management Extensions (JMX)

Since Sun's Java Version 1.5 JMX is bundled with the JDK. The JDK also includes a small JMX client application JConsole, which can be used to connect to a running application using JMX. TDA is available as a plugin for JConsole. JMX is also available with VisualVM, a new troubleshooting tool. included in recent Java VM's starting with 1.6. See Application Analysis using JConsole for detailed information on how to use JConsole with the TDA Plugin.

Using jstack

Also starting with Sun's JDK 1.5 you can also request a thread dump using the JVM utility jstack. jstack prints the thread dump into the shell window where you called it. To use the dump in TDA, pipe the output into a log file and open this file. To analyze multiple dumps just append them to the log file. jstack also allows you to get thread dumps from javacore-files, either dumped on an OutOfMemoryError or using the JVM tool jmap. On the windows platform this tool is available starting with JDK 1.6. It is not available at all on the linux-ia64 platform.