How to generate Heap dump on OutOfMemory error

Memory leaks happen often and at times become tricky to reproduce. It’s worth while to generate Heap dump when an OOME occurs. Let’s see how what are the command line options that controls them.

Add the following options to command line while launching the Java Application

-XX:+HeapDumpOnOutOfMemoryError – Tells JVM to generate Heap dump on OOME
-XX:HeapDumpPath – Specify the path where Heap dump is to be generated

Let’s see a sample

One thought on “How to generate Heap dump on OutOfMemory error

Leave a Reply

Your email address will not be published. Required fields are marked *