How to manually generate a Heapdump in Websphere

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

Method 1: Using Kill command in unix
1) Login n the Administrative Console:
2) Navigate to  Servers > Application Servers > serverName:
3) In the Server Infrastructure section open Java and Process Management, then select Process Definition:
4) In the Additional Properties select Java™ Virtual Machine:
5) Add the following string to the Generic JVM arguments field:
-Xdump:heap:events=user
6) Press OK, and save the configuration.
7) Recycle the App Server for the changes to take effect

genericjvmargument1
To generate the heapdump, send the Application Server an interrupt. Use the “kill” command:

kill -3 <java process ID>

This will not “kill” the Application Server process, it just generate the heap  dump and thread dump in the Profile_HOME

Method 2: wasadmin command
1)Wsadmin provides functions to trigger a heapdump or javacore manually.
2)To call this functionality you need to first query the JVM MBean you are interested in and can then invoke “generateHeapDump” or “dumpThreads” functionality.

Invoke the generateHeapDump operation on a JVM MBean, for example,
a) Finding JVM objectName:
   wsadmin>$AdminControl queryNames type=JVM,*
WebSphere:name=JVM,process=server1,platform=proxy,node=IBM-ADCC282A82BNode04,j2eeType=JVM,J2EEServer=server1,…

b) Set the  variable for the concerned server
wsadmin>set jvm [$AdminControl queryNames type=JVM,*]
WebSphere:name=JVM,process=server1,platform=proxy,node=IBM-ADCC282A82BNode04,j2eeType=JVM,J2EEServer=server1,…

(set jvm is just a name given for the variable )

b) Invoking the generateHeapDump operation on JVM MBean:
wsadmin>$AdminControl invoke $jvm generateHeapDump

 

Method 3: Environment Entries

Update the Environment variables for the Path where you want to generate the heap , core and thread .. for each JVM where you want it set. I want the dumps generated under /appprofiles/server1/

a) Create the necessary directories

mkdir -p /appprofiles/server1/core
mkdir -p /appprofiles/server1/heapdump
mkdir -p /appprofiles/server1/javacore

b) In the admin console Navigate to the below path

Application servers > server1 > Process definition > Environment Entries

c) Set these Environment Entries

IBM_JAVACOREDIR
/appprofiles/server1/javacore

IBM_HEAPDUMP
true

IBM_HEAPDUMPDIR
/appprofiles/server1/heapdump

IBM_HEAP_DUMP
true

IBM_COREDIR
/appprofiles/server1/core

d) Restart the server

e) You can use kill-3 pid to generate the dumps . it will get created in the specific path you have mentioned

Also when the application server will automatically generate the dumps it will get created in the above path

 

3) heap dumps can be found under profile_rootprofile-name with naming heapdump.<date>..<timestamp><pid>.phd

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>