Thursday, September 6, 2012

Detecting Memory Leaks in SharePoint 2010

In this article we will discuss how we can detect memory leaks while working SharePoint 2010 object model. You can also check an article on SharePoint 2010 best practices. You can also check an article on SharePoint 2010 designer best practices and also you can check Causes of Performance issues in SharePoint 2010.

Memory leaks are very much in SharePoint. If we will not properly dispose SharePoint objects then you can get error like this: "Detected use of SPRequest for previously closed SPWeb object "

SPDisposeChecker is a very good tool to detect memory leaks in SharePoint 2010. First download
SPDisposeChecker from this URL and then follow the below steps:

Step-1:
First run the .msi file, as shown in the figure below. and then click Next.

Step-2:
In the next dialog box accept license agreement and click Next as shown in the figure below.

Step-3:
In the next dialogbox check the both check boxes for Default Options for SPDisposeCheck Visual Studio Addin as shown in the figure below.

Step-4:
Then in the next dialog box, select the installation folder and click on Next as shown in the figure below.
Step-5:
Then the installation will progress as shown in the figure below:

Step-6:
After that installation will complete as shown in the figure below.

Step-7:
Once the installation complete, when you open visual studio 2010 then one Option will come like SharePoint Dispose Check under the Tools menu as shown in the figure below.

Step-8:
Once you will click on the "SharePoint Dispose Check" option in from the Tools menu, a SPDisposeCheck dialog will come with option to Analyze as shown in the figure.

Through the "Select the assemblies to analyze:", you can select the assembly which ever you want to analyze. Now when you will check View -> Error List. You will able to see memory leaks there.

No comments:

Post a Comment