How to create a heap dump in WebSphere

Home > Search > How-to
  by

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.

 


JVM default dump settings

By default, JVMs are configured to automatically create a heap dump when certain events occur. Events that trigger a dump can be added or removed using the Java command with the -Xdump option or the JAVA_DUMP_OPTS environment variable. The -Xdump option is preferred over JAVA_DUMP_OPTS. For example, the following command disables default heap dumps and then enables a heap dump when a full garbage collection event occurs.

/opt/IBM/WebSphere/AppServer/java/8.0/jre/bin/java -Xdump:heap:none -Xdump:heap:events=fullgc class [args...]

 

It may be easier (and more pratical) to configure Xdump using the admin console.

  1. In the left panel of the WebSphere web console, expand Servers > Server Types, and select WebSphere application servers.
  2. Select the JVM.
  3. Expand Java and Process Management and select Process definition.
  4. Select Java Virtual Machine.
  5. In Generic JVM Arguments, add the Xdump command you want to use.
  6. Select OK.
  7. Select Save.

 

If using the JAVA_DUMP_OPTS environment variable, one of the following commands would be used to set the environment variable.

JAVA_DUMP_OPTS="ONANYSIGNAL(HEAPDUMP)"
JAVA_DUMP_OPTS="DUMP(HEAPDUMP)"
JAVA_DUMP_OPTS="ERROR(HEAPDUMP)"
JAVA_DUMP_OPTS="INTERRUPT(HEAPDUMP)"
JAVA_DUMP_OPTS="EXCEPTION(HEAPDUMP)"
JAVA_DUMP_OPTS="OUTOFMEMORY(HEAPDUMP)"

 


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 server4 JVM.

 

After the heap dump is created, the location of the heap dump will be listed.

 


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

 

After the heap dump has been created, you will want to analyze and respond to the heap dump.

 



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.




Comments