Search code examples
javamultithreadingdebuggingjvmremote-debugging

How do I debug hanging threads in the JVM?


I am running a durable Java program on a remote Ubuntu server, where I have root user rights. After some time, the usage on some CPU cores goes up to 100%. The logs show nothing suspicious and the application still works, but with reduced throughput.

How can I debug the JVM so that I can find out the cause of this, while it's still running?


Solution

  • One option is VisualVM, which is included in the JDK starting with Java 1.6. I have found it useful in some situations in the past.

    You may connect to local applications or remote applications.

    To connect to a remote app, run jstatd on your remote server, and then run VisualVM locally and enter your server's IP address. You should be provided with a list of running Java applications including the one you wish to explore. If you have any trouble listing your application, good documentation is available at the VisualVM website.