Thursday, August 18, 2011

SPDisposeCheck for SharePoint 2010

In this post we will discuss a very useful SharePoint tool which is known as SPDisposeCheck. Also you can check out my previous posts on:

SPDisposeCheck is a tool that analyzes the custom SharePoint solution that uses SharePoint object model. If you can using SPSite or SPWeb objects then it is very much necessary to dispose the objects.Many SharePoint API's allocate COM based memory that is not released by CLR garbage collection and must be released by calling the Dispose() methods. If the objects will not be disposed propertly, this you will get the error as "Detected use of SPRequest for previously closed SPWeb object SharePoint 2010". Check for more information.

There are also some objects which should not be disposed, for more information you can read this article.

As the name suggests SPDisposeCheck will ckeck your assemblies and will let you know the memory leaks according to the Microsoft standards. It is a command line utility and called by the Visual studio addin. It takes  path to a managed .DLL or .EXE or the path to a directory containing many managed assemblies. Then it starts analyzing the memory leaks.

You can download the from the below URL

After downloading this and during installation you can tick on the check boxes to integrate SPDisposeCheck to visual studio 2010.

Once the Integration happens it can be found under Tools -> SharePoint Dispose Check in Visual Studio.