Call Me at +91 7798846928 for Trainings

My photo
I am a Middleware Trainer and Consultant for Websphere (WAS, MQ), Weblogic, SOA and JBOSS Administration. Drop a mail to kvn@live.in for trainings and videos or call on +91 7798846928 for details.

Wednesday, February 19, 2014

How to generate Heap Dumps manually in Websphere Application Server 7 and analyze?

Although heap dumps are generated only in response to a detected memory leak, you must understand that generating heap dumps can have a severe performance impact on WebSphere Application Server for several minutes. When generating multiple heap dumps manually for memory leak analysis, make sure that significant objects are leaked in between the two heap dumps. This approach enables problem determination tools to identify the source of the memory leak.

On JVM in WebSphere Application Server, you can manually produce heap dumps by using the wsadmin tool to run scripts with generateHeapDump operation on MBeans. 
On a Java virtual machines (JVM) in WebSphere Application Server, you cannot enable automated heap dump generation.
 WAS supports the Jacl and Jython scripting languages only, which will be used to interface with WAS through wsadmin.

Steps involved:

1.    Start the wsadmin scripting client.

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

2.    Invoke the generateHeapDump operation on a JVM MBean, for example, 
<wsadmin> $AdminControl invoke $objectName generateHeapDump
 
 
where, 
The following table explains variables in the command previously mentioned.
$ is a Jacl operator for substituting a variable name with its value
invoke is the command
generateHeapDump is the operation you are invoking
<servername> is the name of the server on which you want to generate a heap dump
<nodename> is the node to which <servername> belongs
 
After running the wsadmin command above, the file name of the heap dump is returned.

How to analyze a heap dump generated either wise?

Do not analyze heap dumps on the WAS machine because analysis is very expensive (CPU and disk I/O intensive). For analysis, transfer heap dumps to a dedicated problem determination machine.

Steps involved:

 1.    On the physical application server where a memory leak is detected, go to the WebSphere Application Server home directory (WAS_ROOT\PROFILE_ROOT\ProfileName).
2.     Heap dumps generated here will be in below format:
         heapdump.<date>.<timestamp>.<pid>.phd 
3.     Gather all the .phd files and transfer them to your problem determination machine for analysis.
Note: In some environments they will be configured to plain text format, you can toggle this on adminconsole websphere variables section.
4.     "Memory Dump Diagnostic For Java" is the tool from IBM for heap dump analysis and verbose GC analysis. There are many other third-party tools available to do the same.

No comments:

Post a Comment