[frs-278] How to get a thread dump from the JVM


Background

To assist in debugging potential issues it is sometimes necessary to generate a thread dump. This is a list of all threads in the JVM and their current stack of processing code.

Generating a thread dump

Preferred method: If you have access to FusionReactor, you can goto the "Resource->List All Threads" page in the left-hand menu, then click the "Stack Trace ALL" button at the top-right of the page.

Other ways to generate a thread dump differ depending on the platform:

Windows systems

  • Press Ctrl-Break in the command console you used to start your application.
    • If a command console isn't an option (eg when started as a service) you can use a tool like StackTrace to get a stack trace. At the time of writing, the licence allows free use when started with the JNLP Web Start option.
  • If you start your application with the com.sun.management.jmxremote option you should be able to attach jconsole and get a thread dump (JDK 5.0 or higher.)
  • There is a little tool called SendSignal which uses a clever trick to call the ctrl-break signal handler of any process.
  • JDK 5 & 6 offer tools for monitoring, management, and troubleshooting (jconsole, jps, jstat, jstatd, jinfo, jmap, jstack.)

Mac OS X

  • Press *Ctrl-* in the terminal console you used to start your application.
  • You can also generate a thread dump by sending the QUIT signal to the Java VM running your application kill -QUIT process_id where process_id is the process number of the respective java process.
    • Note: This method outputs the stacktrace to the standard output stream which may be redirected to a log file.
  • Thread dump by using gdb.
    • Attach to the target process with gdb and run the following command:
    • (gdb) call (void)pss()
  • The latest Apple 1.5 JVMs offer all the monitoring tools available for Linux and Solaris (jconsole, jps, jstat, jstatd, jinfo, jmap, jstack.)

Unix systems

  • Press Ctrl- in the terminal console you used to start your application.
  • You can also generate a thread dump by sending the QUIT signal to the Java VM running your application kill -QUIT process_id where process_id is the process number of the respective java process.
    • Note: This method outputs the stacktrace to the standard output stream which may be redirected to a log file.
  • JDK 5 & 6 offer tools for monitoring, management, and troubleshooting (jconsole, jps, jstat, jstatd, jinfo, jmap, jstack.)

Issue Details

Type: Technote
Issue Number: FRS-278
Components: Logging
Environment:
Resolution: Fixed
Last Updated: 08/Nov/11 3:01 PM
Affects Version:
Fixed Version: 4.0.0
Server:
Platform: Windows XP, Windows 2000, Windows 2003, Linux, MacOS, Solaris, Windows Vista, Windows x64, AIX, Windows 7, Windows 2008
Related Issues: