May 16
JVM Monitoring Tools For ColdFusion
Posted by James Netherton | Friday 16 May 2008 11:29 AM | In ColdFusion,Java
I've been experimenting with JVM monitoring tools out of curiosity for what impact some applications have on memory and CPU usage. Here is a brief rundown on some of the tools that I used. All of these tools should be included within the bin directory of whatever JDK distribution you are using, providing the Java version is 1.5 or greater.
You may read this post and wonder why I bothered to research any of this, seeing as ColdFusion now has built in monitoring and profiling tools, together with many third party alternatives. Those tools are all good at providing a relatively high level of detail, showing what's going on inside of the application server but the tools outlined below can offer a more granular level of detail.
jps
Some of the tools require an argument to specify the id of the JVM that you want to interrogate, jps can be used to retrieve this id:
358 Jps
268
Other tools require that you pass an argument for the JVM process ID. This information can be easily obtained by using Task Manager, Activity Monitor, top, ps or whatever your tool of choice is for your environment.
JConsole
JConsole is a graphical tool that displays the current state of the JVM in terms of memory usage, thread usage and classes loaded. There are a couple of other items such as MBean management, but that's outside the scope of this post.
To start JConsole you need to the process ID of the JVM. I'm going to use the PID of JRun (2219) which of course is my ColdFusion JVM instance:
You'll then see graphs representing the current JVM memory usage. Execute some CF pages or fire up an application and you should see the memory graphs rise and fall as memory is allocated and garbage is collected. You can even force garbage collection by clicking the 'Perform GC' button.
jstack
jstack produces a stack trace dump of all threads within the JVM.
Note that the output is very verbose so it's probably better to pipe the output to a file.
jmap
jmap can be quite useful to gather details about JVM memory details. For example, you can view heap statistics relating to number of objects loaded and the amount of memory allocated. Again, it's best to pipe the output to a text file:
jstat
jstat displays performance statistics for a JVM instance. The tool requires the id of the target JVM to be passed as a command line argument. You can also set the data refresh rate by specifying a value in milliseconds. The example below outputs a summary of garbage collection statistics every 5 seconds:
There a many different switches that can be used to obtain different monitoring statistics. The Sun jstat web page has an overview of these options.
Some other tools that I looked at:
visualgc - similar in some ways to JConsole but focuses on memory and garbage collection statistics.
profiler4j - I couldn't get this working with JRun.
Eclipse Profiler - I got the Eclipse plugin installed ok but JRun choked whenever I tried to start ColdFusion after adding the specified profiler arguments into the jvm.config file. I only tried this with CF 8 so it may work with CF 7 and Java 1.4.2.
JRockit Mission Control - A product from BEA. It has been used to good effect in the past to find memory leaks in ColdFusion:
Mike Schierberl - ColdFusion Memory Leaks
Jason Sheedy - Cold Fusion Memory Leak
I got bored of trying to hunt down a free version of JRockit on the BEA website, but this tool can potentially offer some nice insights into what's happening under the hood of an application.
0 Comments
[Post comment]