Getting memory dump without garbage collection

Hi all.

Does anyone know of a way to get a memory dump from the Sun JVM (version 1.5.0_11 for Windows) without garbage collection occurring first? I've tried the -XX:+PrintClassHistogram option, but this always seems to garbage collect before printing the histogram.

My problem is that I see heap usage increasing very rapidly in the JVM, then garbage collection occurs and reduces memory usage back down to what it was before. However, this results in the JVM spending a large amount of time garbage collecting. I would like to be able to see the contents of the heap before GC occurs.

These are the options I've tried so far:

* Using -XX:+PrintClassHistogram. As mentioned above, this always garbage collects before printing the histogram.

* Using -XX:+HeapDumpOnOutOfMemoryError. The problem is that the JVM always manages to GC before running out of memory, so never dumps the heap.

* Using the jmap tool. Unfortunately I'm running Windows (in production), so this is not available for 1.5.

* Using HPROF. However this seems to slow the JVM down hugely (whenever I use -agentlib:hprof=heap=sites or -agentlib:hprof=heap=dump).

* Using the HeapViewer demo tool that comes with the JVM. This has the same effect as PrintClassHistogram and garbage collects before outputting.

* Using JProfiler. Unfortunately it seems (with the 1.5 JVM anyway) the Concurrent Garbage Collector cannot be used in conjunction with JProfiler (I think this is a JVM TI issue?). With the Parallel GC we don't see the same problem (probably mostly because throughput is crippled with the Parallel GC).

* Using jstat. This only gives us statistics about how much has been garabge collected, not which objects were collected.

Has anybody got any other suggestions?

Thanks.

Neil.

[1843 byte] By [neilf79a] at [2007-11-27 2:56:07]
# 1

Hi all.

Just an update on this -- I couldn't find any way to do this in Java 1.5 (on Windows).

In Java 1.6 (and maybe in 1.5 on other platforms) jmap will do a heap dump without garbage collecting.

I also came across an open source memory profiling tool called Ariadna (see http://mernst.org/ariadna/) which seems to work quite well. It was only of limited use in Java 1.5 however, since JVM TI doesn't support the concurrent garbage collector in this version.

Hope this is helpful anyway. I'll be trying to get upgraded to 1.6 ASAP!

Thanks.

Neil.

neilf79a at 2007-7-12 3:33:29 > top of Java-index,Core,Monitoring & Management...