I\'m trying to diagnose a PermGen memory leak problem in a Sun One 9.1 Application Server. In order to do that I need to get a heap dump of the JVM process. Unfortunately, t
If it's 1.5.0_14 or later, you can use -XX:+HeapDumpOnCtrlBreak
and hit Ctrl-Break in the console
There was a new hotspot option introduced in Java6, -XX:-HeapDumpOnOutOfMemoryError
, which was actually backported to the Java5 JVM.
http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
Dump heap to file when java.lang.OutOfMemoryError is thrown. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
It's very handy. The JVM lives just long enough to dump its heap to a file, then falls over.
Of course, it does mean that you have to wait for the leak to get bad enough to trigger an OutOfMemoryError
.
An alternative is to use a profiler, like YourKit. This provides the means to take a heap snapshot of a running JVM. I believe it still supports Java5.
P.S. You really need to upgrade to java 6....