Skip to content
Aitor Gómez-Goiri edited this page Jan 29, 2016 · 4 revisions

This page describes interesting tools and articles to fix bugs or improve the web performance.

Java memory

jmap and jhat

They both come with new JDKs.

  • Make heap snapshot with jmap:
 $ ps -ax | grep "tomcat"
 $ # Let us imagine that it is running in PID 29868
 $ sudo -u tomcat jmap -dump:file=dump.txt,format=b 29868
  • Analyse it with jhat:
 $ # change the permissions of the file if necessary
 $ jhat -port 7000 /tmp/dump.txt
  1. Open the host with the port you specified (by default, 7000) in the browser and explore data.

VisualVM

VisualVM comes with new JDKs.

To enable remote connection, I have done the following in the web server:

  • Created a jstatd.all.policy file:
grant codebase "file:[path_to_jvm]/lib/tools.jar" {
   permission java.security.AllPermission;
};
  • Configure CATALINA_OPTS in tomcat.conf with something like this:
CATALINA_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=5555 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=192.168.34.202
  • Restart tomcat: systemctl restart tomcat
  • Run jstatd: jstatd -p 12345 -J-Djava.security.policy=[path]/jstatd.all.policy

Visual GC

  1. Open VisualVM
  2. Go to Tools > Plugins and install Visual GC
  3. You might need to reestart VisualVM
Clone this wiki locally