[RSS]

How to Generate a Thread Dump

When the NetBeans IDE freezes or becomes sluggish for no apparent reason, it's recommended to generate a thread dump and attach as a file to the reported bug. Please use 'Create a new attachment' link in the 'Attachments' section of the IssueZilla header. Do not copy the thread dump into the description field!

The Thread Dump

... is a textual dump of all active threads and monitors of Java apps running in a Virtual Machine.

To generate thread dump:

  • Windows
    • Press Ctrl-Break in the command console you used to start the IDE
      If the console isn't opened (in case you started the IDE using the default desktop icon):
      • launch the IDE using a console window
        (invoke Command Prompt, go to {netbeans-install-dir}/bin and type nb.exe)
      • configure the desktop shortcut to launch the nb.exe instead of netbeans.exe (default)

  • Unix, Linux, Mac OS X
    • press Ctrl-\ in the terminal console you used to start the IDE
    • send the QUIT signal to the Java VM running the IDE
      kill -QUIT process_id
      process_id is the process number of the respective java process

  • jstack tool
... is a monitoring tool that is part of JDK installation. The documentation:
  1. jstack from JDK1.5.0
  2. jstack from JDK6.0
  3. On Mac OS X, jstack sometimes fails with an error message. As a workaround, you can generate a thread dump using killall -9 hsdbd; sudo jstack pid

  • StackTrace tool
... allows to get thread dump even without console. It works on all platforms and for all JDKs.
  1. launch from http://www.adaptj.com/root/webstart/stacktrace/app/launch.jnlp
  2. details http://www.adaptj.com/root/main/stacktrace

To generate thread dump:

  1. select main menu item "Process|Thread Dump..."
  2. in dialog click "..." button to open process ID chooser
  3. select PID from the list and confirm the chooser
  4. click OK to request thread dump

  • VisualVM
The VisualVM is a tool that provides a visual interface for troubleshooting, profiling and viewing detailed information about Java applications while they are running on a Java Virtual Machine. Available as part of JDK or from download page.

To generate thread dump:

  1. Run VisualVM
  2. Invoke popup menu on the program node
  3. Select Thread Dump