Profiling using JVisualVM

Below the steps required to profile Tomcat at runtime.

  1. Add the following to sentenv.bat if windows and setenv.sh in Unix file in TOMCAT_HOME/bin

SET CATALINA_OPTS= %CATALINA_OPTS%
		-Dcom.sun.management.jmxremote
		-Dcom.sun.management.jmxremote.port=8888
		-Dcom.sun.management.jmxremote.ssl=false
		-Dcom.sun.management.jmxremote.authenticate=false

In windows, the above should be in the same line, in Unix, you can add forward slash \ at the end of each line

  1. Open JDK_HOME/bin/JVisualVM (assuming Oracle JDK)

  2. Add JMX connection and fill the host field 127.0.0.1:8888 (assuming that you are locally troubleshooting Tomcat)

  3. Connect.

You should see something like this:

visualvm

The above shall be used carefully due to performance and security concerns, authentication and SSL should be added as needed.