Thursday, August 13, 2009

Monitoring Java Memory

If you find your app server running out of Java heap space, or just want to monitor it to look for issues, running the Java Monitoring and Management console is a relatively easy method to accomplish this. To set this up, you will need to add the following to the startup properties for the JVM, typically the run.bat (or run.sh) file:

-Dcom.sun.management.jmxremote.port=6778
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

This starts the JVM with a monitoring server on port 6778 (you can pick any port you want, just change the number above). Then, from your desktop (you must have the JDK 1.5+ installed, not just the JVM) you would run the following at a command prompt:

java -jar jconsole.jar appserver:6778

Where "appserver" is the hostname or IP address of the app server. If jconsole isn't in your path, you should be able to find it in the "bin" directory under your JDK installation. That should pop up a handy console window where you can monitor various statistics on the server. One thing to watch for is "PS Old Gen" completely filling up, as this will make your TRIRIGA server non-responsive.

If you don't have the JDK installed (but have a JVM) you can still access the JConsole by just downloading the jconsole.jar file to your local system and running the above command from the same directory.

Thanks to Eric Glass for this tip!