Create JavaOutOfMemory Crash Dump

Create JavaOutOfMemory Crash Dump:

Sometime Java Application crashes due to out of memory exception. If we don't have the proper logging mechanism, we won't be able to find out why the application has crashed. We can use the Jconsole or Jprofiler to debug the memory leak. But if our application crashes after running for 3-4 hours, it will be difficult to debug without having proper dump.
Java provides some useful arguments, using which we can create the core dump using very few arguments.
We can add below arguments in the JVM to get the dump:
                java -ms32m -mx512m -XX:+HeapDumpOnOutOfMemoryError.
By adding the above argument, when the application crashes, It will create the dump with name : java_pid.hprof