views:

1126

answers:

5

Having analyzed a light-load web application running in tomcat, using JMX Console, it turns out the "PS Old Gen" is growing slowly but constant. It starts with 200MB and grows around 80MB/Hour.

CPU is not an issue, it runs at 0-1% on average, but somewhere it leaks memory, so it will become unstable some days after deployment.

How do i find out what objects are allocated on the heap? Are there any good tutorials or tools you know?

+2  A: 

You could try jmap, one of the JDK Development Tools. You can use jhat with the output to walk heap dumps using your web browser.

See this answer for a short explanation.

This comes up quite often, so searching SO for those tools should turn up some alternatives.

McDowell
+1  A: 

I've used the HeapAnalyzer tool from IBM's alphaWorks with good success. It takes output from Java's heap profile, hprof, and analyzes it to show you the most likely memory leaks.

erickson
+1  A: 

You can use NetBeans profiler. It has 2 modes, launching tomcat profiled directly from ide (for localhost) or using a remote profiling with a JAR provided and some run config on server.

I used it in a project for a memory leak and it was useful.

jberges
A: 

JRockit Mission Control can analyze memory leaks while connected to JVM. No need to take snapshots all the time. This can be useful if you have a server with a large heap.

Just hook the tool up to the JVM and it will give you a trend table where you can see which type of objects that are growing the most, and then you can explore references to those objects. You can also get allocations traces, while the JVM is running, so you can see where in the application the objects are allocated.

You can download it here for free

Kire Haglin