Tuesday, June 21, 2011

.Net Memory Profiler

[22/06/2011]
.Net memory profiler is a tool which is used for analysing the memory consumptions of an application. All that has to be done is: Invoke an Application using the profiler and at a given point of time when we have performed our operations with the application, click on the Get Snapshot button on the Profiler tool bar. This would get the current bytes which are being consumed by the application. I perform this operation to analyse whether there are any memory leaks in the application.

HOW TO ANALYSE MEMORY LEAKS
Perform one operation and take the memory snap shot. this would give you the bytes and the objects that are still held by the application.
Perform the same operation again and take the memory snapshot. The profiler would open the previously taken snapshot and compare it with the newly taken snapshot, any positive value as a a differnce would mean that it is a memory leak: This means that on subsequent performance of the same operations, the memory consumed by the application should not increase.

Now we need to investigate in the positive values that we have got in order to fix the memory leak.

.Net Memory profiler gives the leaks in terms the object types along with their namespaces. Hence it is pretty easy to identify the type of the object which is getting leaked. It also provides with the root path for the leaked objects. Hence for a given leaked object we can check the root path. All that we have got to do is some how cut the link in the root path. Once the link is cut in the root path then the given object becomes isolated and is eligible..Net GC comes and garbage collects this object.

No comments:

Post a Comment