views:

27

answers:

1

I have a Tomcat Java webapp which is thrashing the Java GC when under load. I think this is due to a combination of a large amount of short lived objects along with an unknown amount of moderately long lived objects.

To validate this theory I want to find a tool which will let me determine the object lifetimes for all allocated objects (or every 10th object etc for better performance). Ideally the final output will be a histogram showing the relative number of objects which live for different amounts of time.

I think this tool will likely be built on top of either the Instrumentation API or the JVMTI. If there are no good tools which already do this I would also appreciate suggestions about which of the JVM's interfaces would be best to use when writing such a tool.

A: 

I have now started writing a tool to do what I originally asked about. The current code can be found here:

http://wiki.github.com/mchr3k/org.inmemprofiler/

So far I have managed to get a textual histogram of all object allocations by instance count. This does not include array allocations which are handled differently.

I am now working on adding instance size information along with tracking of array allocations by using the JVMTI.

mchr
This tool can now track object sizes and allocation traces.
mchr