javatomcatout-of-memoryheap-dumphprof

tomcat not generating hprof file on outofmemory error


I have some memory leak issue in my web app which is deployed in tomcat. To find the root cause I enabled the HeapDumpOnOutOfMemory error by setting:

-XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/local/tomcat/logs

and the memory settings in the tomcat is:

-Xms256m -Xmx768m -XX:PermSize=128m -XX:MaxPermSize=256m

When the out of memory issue happened, I see

java.lang.OutOfMemoryError: Java heap space

on the tomcat log file, but the .hprof file is not generated. Am I missing some settings here?


Solution

  • As @beny23 wrote you should use -XX:+HeapDumpOnOutOfMemoryError

    and as is stated here:

    The -XX:HeapDumpOnOutOfMemoryError Option This option tells the Java HotSpot VM to generate a heap dump when an allocation from the Java heap or the permanent generation cannot be satisfied. There is no overhead in running with this option, so it can be useful for production systems where the OutOfMemoryError exception takes a long time to surface.

    Check also your Java version since this option was introduced in 1.4.2 update 12, 5.0 update 7.