How Do I Generate Heap Dump?
Heap Dumps are vital artifacts to diagnose memory-related problems such as slow memory leaks, garbage collection problems, and java.lang.OutOfMemoryError. They are also vital artifacts to optimize the memory consumption. There are various platforms to generate a heap dump. This section explains few platforms from where you can generate a heap dump. You can choose any platform according to your requirement.
- Java 7 version and above is considered for generating dumps.
- To check the Process ID (PID) of the webMethods API Gateway JAVA application :
Linux: Run the following command ps –ef | grep java Windows: JAVA PID is available in the Task Manager
Generate Heap Dump using jmap
The jmap tool is located in the JRE or JDK_HOME\bin folder. jmap tool generates heap dumps into a specified file location. To generate a heap dump:
jmap -dump:format=b,file=file_path.bin PID
where:
pid. Process Id of the application, whose heap dump should be generated.
file_path. File path, where the heap dump has to be generated.
jmap -dump:format=b,file=/opt/tmp/heapdump.bin 37320
37320 is the PID and the opt/tmp/heapdump.txt is the location where
the heap dump of the process is generated.
Generate Heap Dump using jVisualVM
- Launch the jVisualVM.
- Select your java application from the list in the left pane.
The left pane of the window lists all the java applications that are running on your system.
- Click on the Monitor tab in the right pane.
- Click
Heap Dump button.
The Heap dump is generated.

HeapDumpOnOutOfMemoryError
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=file_path
where file_path is the location and the name of the file, where the
heap dump is generated.