Wednesday, February 21, 2007

Excellent VM flag

This is a bit dated, but if you're using Java 1.5 or 1.4.2, there's an excellent flag in more recent VM updates: HeapDumpOnOutOfMemoryError. OOMs have to be one of the hardest problems to debug: traditionally, you'll have next to zero information on the cause of the crash. This flag apparently has no runtime cost, and will provide a thorough snapshot of the heap at the time of the crash. I hadn't had a "out of heap space"-style OOM in years, but recently had one. Luckily, this flag was enabled, and I was able to use the "jhat" tool to pretty quickly find the culprit. I had some problems with the java.net HAT tool, but the jhat which is distributed with Mustang worked perfectly. This is one of those simple changes that can really save you later.

All the info

1 comment:

Markus Kohler said...

Hi,
You might be interested to check my blog entry from
last year about the new heap dump feature. You will find some details , like how to trigger a heap dump on demand.


Regards,
Markus Kohler