Getting head dumps on OutOfMemoryException

This is one of these notes to self that I keep writing on the blog…

Add the following java options when launching an application (or application server) to get a dump if the application throws an OutOfMemoryException

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/where/to/write/the/dump

We are using this on out local and development servers at work, and then using Eclipse MAT to diagnose the cause.

So far, it is been a pleasure working with MAT. We are maintaining some legacy web application which occasionally crashes due to OOM, so we took a dump and fed it to MAT.

Despite of my attempts to look at the wrong places (since we got OOM) on a webservice, MAT kept showing me our real memory problem until I understood it. The exception on the webservice was only collateral damage… most of the memory was being used in the tests run before the actual crash.

Now we save more than 2.5Mb on each http session, since it turned out that the application was caching too much, too many times (on every session, instead of sharing the data at the application level).

I’m happy :-)

About these ads

  1. Sometimes it’s hard to track OOM issues down, but this Eclipse MAT seems to do a good job. I should keep it in mind.






Follow

Get every new post delivered to your Inbox.

%d bloggers like this: