Sunday, May 3, 2015

Take A Java Thread Dump With A Few Clicks

Using VisualVM, taking a thread dump can be a matter of few clicks. And not only local JVM, you can also connect to remote JVM irrespective of the underlying platform of the remote machine. It can be a Windows or a Linux machine, it doesn't matter as long as it has a JVM to connect to. You just need to specify the port to create a JMX connection to the remote host and that's it.





Check the above screenshot. It's a real time snapshot of local JVM threads in my Windows machine and at the right top corner you can see a button for thread dump. When you click on it, it will generate thread dump and will display it in ui console. Then you can copy or save it as you want. So no need to go to command line and type command to get thread dump in catalina.out or write it in a separate file. VisualVM will take care of it cleanly with a simple interface. VisualVM is shipped with Oracle JDK distribution by default. So you don't need to install it separately. Just go to JDK bin folder and click on jvisualvm.exe to start. It has other cool features. But today I just wanted to focus on taking a thread dump easily. I use it frequently in my Windows laptop to take a java thread dump from remote tomcat servers.

No comments:

Post a Comment