-
Notifications
You must be signed in to change notification settings - Fork 5
Debugging
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.
- 10 points about Java Heap Space or Java Heap Memory
- OutOfMemory
- Simple procedure to debug memory leaks
- Book recommended in different articles
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
- Open the host with the port you specified (by default, 7000) in the browser and explore data.
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
- Open VisualVM
- Go to Tools > Plugins and install Visual GC
- You might need to reestart VisualVM