Thursday 31 October 2013

SPDisposeCheck With Visual Studio

SPDisposeCheck is a great tool to check memory leakage for SharePoint objects. We must check for SharePoint objects should be disposed to improve performance. While using SharePoint server object model we generally use SPSite, SPWeb in our code  which should be disposed to avoid memory leaks.SPDisposeCheck helps to find such memory leaks caused due to SharePoint objects.   
1.    Download SPDisposeCheck
2.       Install SPDisposeCheck and copy the path of installation. In my case it was:
C:\Program Files (x86)\Microsoft\SharePoint Dispose Check\

3.       Add SPDisposeCheck to Visual Studio

A.      Goto  Tools > External Tool..
 



B.      Click Add and provide title for tool. Paste the installation path to Command and do the changes mentioned in below picture.
C.      Check if SPDisposeCheck is added or not
  


4.       Click On SharePoint SPDisposeCheck .

5.       Here you can select whether problem should be treated as warnings or error. For both the option solution can be build and deployed.


6.       Test the solution by deploying or you can just build the solution to get SPDisposeCheck output at Output window of Visual Studio.