Saturday, April 23, 2011

Thread Dump And Heap Dump

Weblogic Thread Dump and Heap Dump ?

Weblogic Thread Dump


Before starting discussion on Thread Dump, Lets first discuss on thread, What is thread exactly it does.

Ok, Lets start with the official definition first - 

thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.

Basically, for every process or program to run on computer we need the system resources like cpu time, RAM etc, it's the thread which which is created by the system for each and every process/program to be executed, it means your system took a small portion of your system resources and assign to that thread, then then thread execute the respective program or process and release the thread or you can say system resources. So, in case of java programs, if your program run as a single threaded then it could be problematic situations for you because if multiple requests are there then the thread would keep all the requests in the queue till finish the current job. On the other hand, if you have multithreaded capabilities then there will be multiple threads to handle multiple requests in parallel, but only the drawback is each thread will be assigned with some system resources as I said earlier So, you have to make sure on thread counts also.  

Same issues happened with weblogic also when situation arises to take and analyze the thread dumps. With weblogic 8.x and old versions you have the capabilities to define the maximum number of threads for processing but 9.x on wards it has been changed and new concept of thread pool introduced where the size of threads create automatically according to the need. 

Thread Dump

So, specific to weblogic, sometimes your weblogic server stop to respond and chewed your complete heap you have defined for the server then, in that condition you have to take the thread dumps multiple times within seconds on minute of interval, this is because, as I said earlier each thread took the resources and since weblogic created the multiple threads so, sometimes some or all threads stuck for some requests or on process and started taking your remaining system resources and a condition come when it stuck and stop processing, that time you have to take the thread dumps, So, 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, and then you can analyze the request being in process which cause thread to be stuck, hung, dead etc.

Heap Dump

We know that we define heap for each of the created managed or admin server since each server is running on it's own jvm and during the access and processing of a particular request, java objects are created inside the jvm heap, so when we take the heap dump it takes the snapshot of the jvm heap which includes the java objects and classes inside the heap at that particular time when heap dump taken.

No comments:

Post a Comment