IBM Support

How to manually generate a Heapdump in WebSphere on Windows



How to generate a heapdump without waiting for an OutOfMemoryError condition to occur.

Resolving The Problem

Occasionally a heapdump needs to be generated without waiting for an OutOfMemoryError condition to occur.

For example: an OutOfMemoryError will probably cause a system outage. On a production system this is not a desired event. If we manually create a heapdump before the OutOfMemoryError generates one, then the application server can be recycled and we will get a heapdump without an unscheduled outage.

The manually generated heapdump will not be as useful as one which was generated by an OutOfMemoryError, but sometimes it can be of some use. The longer we can wait before generating the heapdump, the more likely the heapdump will contain the objects causing the OutOfMemory. If the heapdump is generated too soon, the largest memory user is not likely to be the same largest memory user when the heap is completely full.

  1. From a Windows Command Prompt, enter the wsadmin.bat command to get a wsadmin command prompt.

    Note: If security is enabled or the default SOAP ports have been changed, you will need to pass additional parameters to the batch file in order to get a wsadmin prompt. For example:

    wsadmin.bat [-host host_name] [-port port_number] [-user userid[-password password]

    Note: You can connect wsadmin to any of the server JVMs in the cell. After running the wsadmin command it will display the server process for which it has attached to.
  2. Get a handle to the problem application server:
    wsadmin> set jvm [$AdminControl completeObjectName type=JVM,process=server1,*]

    Where server1 is the name of the application server that you want a heapdump from. If wsadmin is connected to a Deployment Manager and if the server names in the cell are not unique, then you can qualify the JVM with a node attribute in addition to the process name.

    Note: The contents in brackets "[.....]", along with the brackets, is not optional. It must be entered to set the jvm object. Also, note that there is a space between the words "completeObjectName" and "type", but not a linefeed:
  3. Generate a heapdump:
    wsadmin> $AdminControl invoke $jvm generateHeapDump
    3B: If you want a javacore too:
    wsadmin> $AdminControl invoke $jvm dumpThreads
    (Please note that on older versions of WebSphere you will also get a heapdump when you request a javacore, so do not be surprised if you end up with two heapdumps.)

Here are the wsadmin commands, if you want to copy/paste them into the command prompt. Please note the first one is one line, it is just wrapped for display:

set jvm [$AdminControl completeObjectName type=JVM,process=server1,*]
$AdminControl invoke $jvm generateHeapDump
$AdminControl invoke $jvm dumpThreads

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Out of Memory","Platform":[{"code":"PF033","label":"Windows"}],"Version":"9.0;8.5.5;8.5;8.0;7.0;6.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018