Deadlock Debugging in Eclipse
My Eclipse-based product dead-locked this morning.
If I had launched from my Eclipse dev environment, I could use the debugger to show me the threads and locks that are giving me trouble. Darin Swanson has the best explanation of this.
If I had started the product with “-debug -consoleLog‘ or with java.exe instead of javaw.exe, I could have hit ctrl-Break (Windows) to get a thread dump.
But I had started the product from the install bundle, so didn’t have these options. I also didn’t think the deadlock would necessarily reproduce if I re-ran the product. A little research showed I had more tools at my disposal than I originally realized.
If I had started the product with the Java 6 (or with Java 1.5 using the -Dcom.sun.management.jmxremote VM option), I could use jconsole to attach to my process. Besides the stack trace, this allows all kinds of interesting monitoring.
To use the tool, you’ll need the process ID. You can use the task manager on Windows or the JDK tool jps to get the list of Java process IDs.
The JDK tool jstack works great to just get a quick stack dump from the command-line. Again, you’ll need the process ID.
I need to spend some time exploring the JMX tools. Some cool and useful stuff in here.
Another option is Send Signal, a nice program that send the Ctrl-Break signal to your Java process.
Much of the information new to me came from these 2 excellent resources. Both pages have other ways to get stack traces, including on *nix, and other useful debugging tips.