2 Minutes To Code (β Version)

'java' command - 2 minute tutorial

How to specify options for Heap dump path on OutOfMemoryError

As shown in the previous page, you can use the option -XX:+HeapDumpOnOutOfMemoryError to generate a jvm heap dump when the app crashes due to OutOfMemoryError. And this heap dump is created in the current working directory.

You can also pass an option to the java command for the file name where you want the dump to be stored. This option is -XX:HeapDumpPath and the complete command is java -XX:HeapDumpPath=./heapDUmp.hprof HelloWorld . The dump file name can be specified using either a relative or absolute name.