- Use Dispose() appropriately
- Use SPDisposeCheck utility to identify issues
- General rules[No need to dispose from SPContext, If you used new you should use Dispose]
- Use dispose when [enumerating AllWebs or Webs, open web]
- 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: