9

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?

trincot
  • 317,000
  • 35
  • 244
  • 286
Andreas Petersson
  • 16,248
  • 11
  • 59
  • 91

6 Answers6

2

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.

Community
  • 1
  • 1
McDowell
  • 107,573
  • 31
  • 204
  • 267
1

What you are seeing is normal, unless you can prove otherwise. You do not need to analyze the heap when the additional "consumed space" disappears when a GC in the old space happens. At some point, when the used space reaches your maximum heap size you will observe a pause caused by the default GC you use and afterwards the used memory should go down a lot. Only if it does not go down after a GC you might be interested what is still holding onto those objects.

Fabian Lange
  • 1,786
  • 1
  • 14
  • 18
1

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
  • 265,237
  • 58
  • 395
  • 493
1

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
  • 21
  • 1
1

See my answer here:

Strategies for the diagnosis of Java memory issues

And there are also tips here:

How can I figure out what is holding on to unfreed objects?

Community
  • 1
  • 1
opyate
  • 5,388
  • 1
  • 37
  • 64
0

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
  • 6,569
  • 22
  • 27