How to create and analyze a heap dump in WebSphere

Home > Search > How-to

The creation of a heap dump can significantly impact the performance of the application server for several minutes. Heap dumps are used to analyze a memory leak. It is ideal to create two heap dumps. One heap dump should be created as soon as a memory leak is detected. Another heap dump is created when enough memory has leaked. The two heap dumps are then compared as part of the analysis phase of remediating a memory leak.

You will need to ensure a JVM has enough heap space in order to create a heap dump.

Heap dumps can be created automatically or manually. It usually makes the most sense to automatically create heap dumps for JVMs that are having a memory leak.

Memory leaks can be spotted in the JVMs SystemOut.log file, or using a monitoring tool, such as Introscope.


Automatically create heap dumps using the WebSphere web console

Due the performance impact the creation of a heap dump will produce, you need to decide if it is OK to automatically create heap dumps which will impact performance to create heap dumps for memory leak analysis.

  1. In the left panel of the WebSphere web console, expand Servers > Server types, and select WebSphere application servers.
  2. Select a JVM.
  3. Select Performance and Diagnostic Advisor Configuration.
  4. Select the Runtime tab.
  5. Check Enable automatic heap dump collection.
  6. Select OK.
  7. Select Save.

To preserve disk space, if 10 or more heap dumps already exist on the WebSphere application server, additional heap dumps will not be automatically created.


Manually create a heap dump using the WebSphere web console

  1. In the left panel of the WebSphere web console, expand Troubleshooting and select Java dumps and cores..
  2. Check the JVM and select Heap dump.

In this example, a heap dump is manually created for the deployTest2 JVM.


Manually create a heap dump using the wsadmin utility

Launch wsadmin using the Jacl language, and then issue the following commands.

wsadmin> set objectName [$AdminControl queryNames WebSphere:type=JVM,process=<servername>,node=<nodename>,*]  
wsadmin> $AdminControl invoke $objectName generateHeapDump


Transfer the heap dump

Transfer the heap dump from the WebSphere server to another PC, such as your personal laptop. You never want to analyze a heap dump on the WebSphere application server, as this will use significant resources, such as memory and CPU, which will impact the performance of the WebSphere application server. The heapdump should be located in the profile directory of the application server, such as /opt/IBM/WebSphere/AppServer/profiles/profile01, and the heap dump should have the following name syntax.



Analyze the heap dump

IBMs Heap Analyzer can be used to analyze a heap dump.The analysis will identify the Java classes that contain objects that are taking up heap space. A class is a container that contains one or more objects. In this example there is a class called Dog that contains an object called Puppy with a value of Old Yeller. The programmer that created the application that has classes taking up heap space will need to determine if a code change can be made to the application to reduce the heap space being used by the application.

Public class Dog {
  Public static void main(String []args){
    Puppy myPuppy = new Puppy( "Old Yeller" );


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.