Java: Steps for JVisualVM
1. On the tomcat server, do the following:
a. Open the firefwall to allow connections over the jmx port
b. Make the following directories
mkdir -p /home/tomcat/.jvisualvm/7u6
chown -R tomcat:tomcat /home/tomcat
c. Add the following java options to tomcat in setenv.sh
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9004
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
d. Restart tomcat
e. In order to get a memory and heap dump properly, you should start JVisualVM as the user that started the JVM process you will attached to. In this case 'tomcat'.
xhost +
cd /opt/apps/java/java/bin
su -c "./jvisualvm"
f. You should now be able to capture a heap dump from one of the tabs in the form of an hprof file which can be used with MAT in eclipse.