Thursday, November 25, 2010

heap dump, thread dump and deadlocks in threads

A heapdump is a snapshot of JVM memory - it shows the live objects on the heap along with references between objects. It is used to determine memory usage patterns and memory leak suspects.

When a heapdump is created , a GC is run so that only the live objects are avaliable in the heapdump


generally when an Out of memory exception occurs it creates a heapdump .. though u can do it manually too .

A heapdump is really imp during troubleshooting of the performance, memory leak issues

...
Thread dump

A thread dump is a way of finding out what every thread in the JVM is doing at a particular point in time

so it gives which which methods are being run , any bottleneck and hangs etc

....

Memory Leak

IF any application eats more & more system memory and never seems to return memory back to the system untill large amount of physical memory allocation to that application then this is the sign of memory leak.

So there wouldn't not be sufficient memory to run live objects .

--------------------------------------------------------------------------------


Deadlock

this is when two threads each hold a resource that the other one wants. Each blocks, waiting for the resourse that it's waiting for to be released - and so the resources are never released, and the application hangs .

so to put it in simple way

Thread 1 is using resource A and it wants resource B
Thread 2 is using resource B and it wants resource A

so thread1 will say that only if Thread2 release Resource B then only it will release Resource A

and thread2 will say that only if thread1 release Resource A then only it will release ResourceB

and neither thread 1 or 2 give up and this results in deadlock situation which results in application hang

No comments:

Post a Comment