IBM Support

How do I capture a memory snapshot on an Out of Memory (java.lang.OutOfMemoryError: Java heap space) error with Tomcat?

Question & Answer


Question

How do I capture a memory snapshot on an Out of Memory (java.lang.OutOfMemoryError: Java heap space) error with Tomcat?

Answer

An Out of Memory error ( java.lang.OutOfMemoryError: Java heap space ) is being displayed in the debs logging. Heap Dumps are useful during troubleshooting performance issues. The following steps describe how Heap Dumps can be collected using Tomcat:

   1. Traverse to the bin folder of Tomcat and select the catalina.bat file
   2. In catalina.bat, check where JAVA is getting called and pass the '-Xrunhprof:file=dump.hprof,format=b' argument along with the memory arguments.
   3. In case of out of memory error, please pass '-Xrunhprof:file=dump.hprof,format=b -XX:-HeapDumpOnOutOfMemoryError'
 

To specify the Heap Dump path, add -XX:HeapDumpPath=<path> to the parameters (i.e. - -XX:HeapDumpPath=./java_pid.hprof)

For Tomcat, pass the argument like shown below:

a) Search for %_EXECJAVA%, and add the above parameters to that line like this:

b) %_EXECJAVA% -Xmx1024m -Xms1024m -XX:MaxPermSize=128m Xrunhprof:file=dump.hprof,format=b -XX:-HeapDumpOnOutOfMemoryError %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%

The memory arguments might vary as per the scenario/testing required.   

[{"Product":{"code":"SS6PEW","label":"IBM Sterling Order Management"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Component":"MCS","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Historical Number

FAQ3267

Document Information

Modified date:
16 June 2018

UID

swg21517730