Thursday 14 August 2014

Avoiding Memory Leaks SP2010

In this article we will discuss how we can detect memory leaks while working SharePoint 2010 object model.
  1. Use Dispose() appropriately
  2. Use SPDisposeCheck utility to identify issues
  3. General rules[No need to dispose from SPContext, If  you used new you should use Dispose]
  4. Use dispose when  [enumerating AllWebs or Webs, open web]
  5. Don't use dispose with  [Parent web, RootWeb] 
Step 1: Go to C: --> ProgramFiles-->Microsoft-->SharepointDispose check
Step 2: Select SPDisposeCheck.exe. Copy fill path paste in CMD prompt


Step 3: Go to c:--> users\Select your user-->Documents\Visual Studio 2010\Projects\ExploringTheObjectmodel --> ExploringtheObjectModel --> Bin --> Debug
Copy this path and paste in cmd.

Step 4: Result of Out.txt.



Step 5: Open Code


Memory Leaks




 Step 6: Go to build Events --> post-build Event command Line paste fill path of  SPDisposeCheck.exe. 

Next

Output: