tisdag 29 september 2009

Monitoring JVM

I have been having some trouble with a Glassfish installation, version 2 build 58g. The HTTPS connections seems to be little slow sometimes.
Reading the logs did not get me any information so i needed to find some other tools.

First of all, using kill -3 on a process gives some information. It gives a dump of the threads and shows possible deadlocks. For glassfish look in log jmv.log.

Then we have jconsole that is pretty good. The only problem with that one is that it is almost impossible to access to a remote host because of firewalls because of some unknown ports that are used for the RMI connection. You can write your own JMX agent that only listens to one port and tunnel to it or you can run a VNC server on remote server, that might as well. What is good with Jconsole? It shows memory usage, gives possibility for JMX configuration, shows threads and a lot more.

Another tool i found today (it has been there all the time in Java 6) is jmap.
With it you can create a dump of all memory used. It shows all classes, instances, dependencies and a lot more. The amount of information is amazing and I'm still trying to learn how to find more.

To analyze the dump done by jmap you need to run jhat. It reads the dump and starts a small HTTP server where all the data can be accessed.

These three tools i mentioned can all be found in JRE/bin directory.

Another tool i found is Visualvm but i have just not figured out all the advantages with it, trying to learn.

Inga kommentarer: