Monday, 16 July 2012

Diff Between Heap dump And Thread dump

Diff Between Heap dump And Thread dump

Thread Dump:
When we trigger a thread dump on an application server, all active thread information will be dumped into file which is normally known as thread dump. In this dump file, we can get information about thread like active thread, hung thread, dead lock, runnable and inactive thread info.
Command to generate thread dump: kill -3 PID_OF_SERVER
When our application server reports the thread hung conditions in SystemOut.log file then we generate thread dump to analyze the reason behinds thread hungs. We are generally having thread hung situation when any threads coming to system becomes unresponded.
When Websphere Application Server detects that a thread has been active longer than the time defined by the thread monitor threshold then it write below error code in SystemOut.log file:
 WSVR0605W: Thread threadname has been active for hangtime and may be hung. There are totalthreads threads in total in the server that may be hung.
Where: threadname is the name that appears in a JVM thread dump, hangtime gives an approximation of how long the thread has been active and totalthreads gives an overall assessment of the system threads.
If the above thread gets released by itself then we get below entry in our log file:
 WSVR0606W: Thread threadname was previously reported to be hung but has completed. It was active for approximately hangtime. There are totalthreads threads in total in the server that still may be hung.
Heap Dump:
Heap dump is a text file which keeps record of all objects in the java heap. It contains the information like size and address of all objects, as well as the addresses of all objects that it references.
Before generating the heap dump, we need to enable the garbage collection to get only live objects information in dump.
By Default, whenever OutOfMemoryException occurs Websphere application Server create heap dump in profile’s home directory.
Heap dump is nothing but a snap shot of our JVM’s Heap memory, so here we can have all active java objects and their activities which object doing what and how much memory it is occupying.

1 comment: