Skip to Content

When a system is facing ‘out of memory’ errors (OOM), the best option to understand what is going on there is to create a heap dump (a picture of the content of the memory on a given point of time).  The heap dump generation depends on the kind of JDK we are using (and this also depends on the kind of operating system), but all the JDK versions have options to generate these dumps.

CONFIGURATION

If we use the Sun (1.4.2_12 or higher) or HP-UX (1.4.2_11 or higher) JDKs  we have to follow the instructions of SAP note 1004255. Basically, we have to add the following parameters to our JDK configuration:

  • -XX:+HeapDumpOnOutOfMemoryError
  • -XX:+HeapDumpOnCtrlBreak
  • -XX:HeapDumpPath

The -XX:+HeapDumpOnCtrlBreak parameter triggers a heap dump whenever a CTRL_BREAK event appears. This means that we can create them manually, but if we are not going to do that it is better to remove the parameter. The CTRL_BREAK event is triggered any time we create a thread dump with our SAP Management Console, or when the system itself creates the thread dump. So if -XX:+HeapDumpOnCtrlBreak is set we can find a collection of unwanted heap dumps consuming space in our file system. In general, if we want to obtain the heap dump when the system faces the OOM error, then we only need to set the -XX:+HeapDumpOnOutOfMemoryError option.

In the other hand the -XX:HeapDumpPath=[path/filename] option only works for heapdumps produced by the -XX:+HeapDumpOnOutOfMemoryError functionality. It has no effect on dumps produced by HeapDumpOnCtrlBreak.

At the end, this parameters generate directly .hprof files which can be analyzed with the great SAP Memory Analyzer tool (or MAT).

 

If we are using the IBM Hybrid JVM 1.4.2 with J9 for AIX, then we need to make a different configuration, as described in note 1053495. The parameter in this case is:

-Xdump:heap:events=user

This parameter generates a .phd file which cannot be used with MAT. It contains more or less the same information than a .hprof file, but the analysis is quite tedious. If we want to benefit from using the Memory Analyzer, then we have to make an upgrade to JVM 1.4.2 with J9 SR12 or higher. The configuration will be slightly different, as per note 1259465, using:

-Xdump:system:events=user,request=exclusive+prepwalk+compact

And this will generate a .dmp file which can be read by the SAP Memory Analyzer Tool.

Some other notes describing how to obtain a heap dump depending on the operating system:

  • For OS400 we should check note 1267126: IBM i: How to get a heapdump which can by analyzed with MAT
  • For the IBM JVM 1.4.2 64bit SR12 for IBM power Linux we should check 1265455: How can you generate a system dump for analysis using MAT?   

 

ANALYSIS

Once we have our heap dump, we can use the MAT tool for analysis. This tool can be obtained from the following URL :

http://www.eclipse.org/mat/

If we are using the .dmp files we mentioned before, then we need to additionally install an IBM plug-in in our MAT tool. The plug-in can be downloaded from:

http://www.ibm.com/developerworks/java/jdk/tools/mat.html

It is important to have a least 4Gb of memory in the machine where the MAT is installed to load the heap dump (as they are usually 1 to 2Gb). For more information on this, please check the detailed SDN wiki at:

https://wiki.sdn.sap.com/wiki/display/Java/Java%20Memory%20Analysis

And if you have some questions on this, don’t hesitate to visit the dedicated SDN forum for the Java Development 

Enjoy!

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Hemanth Kumar
    Hi Desiree,
    Really nice blog.
    Next time I will also mention  this in the message so that it will be easy for customers and SAP support finds it little bit easier 🙂

    Regards,
    hemanth

    (0) 

Leave a Reply