Do you need a heap dump?
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.
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:
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:
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:
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?
Once we have our heap dump, we can use the MAT tool for analysis. This tool can be obtained from the following URL :
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:
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:
And if you have some questions on this, don’t hesitate to visit the dedicated SDN forum for the Java Development