Getting memory dump without garbage collection
843798May 1 2007 — edited May 9 2007Hi 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.