SP2010 (SharePoint 2010)

I Send my Experience about Microsoft SharePoint 2010 here... I hope be Useful

Check Memory Leaks in SharePoint WebParts

posted Apr 8, 2012, 3:46 AM by mb s

hi ...
when you are coding a WebPart in VS2010 , you may need to get your Website Context .
to do that , you should Write :

using (SPWeb oWebSite = SPContext.Current.Site.AllWebs["myOtherSite"])

Note that you must Write your Code in the Using Block . if you do not do ,
the SPDisposeCheck.exe shows the Disposable type not disposed message BUT how to see this ?

GO "C:\Program Files (x86)\Microsoft\SharePoint Dispose Check\SharePointDisposeCheck.exe"
and Copy this Address to a Notepad file

Copy your WebPart Directory Path , too.
like : "c:\users\Administrator\Documents\MyFolder\ProjectName\bin\debug"
Write these 2 address like this Command in the command Prompt:
c:\Temp> "C:\Program Files (x86)\Microsoft\SharePoint Dispose Check\SharePointDisposeCheck.exe" "c:\users\Administrator\Documents\MyFolder\ProjectName\bin\debug" > output.txt
AND Press Enter

NOW you have a output.txt file that contains Report about your Disposable Object
[if you do not write  > output.txt ,you will see the Result in same Command Prompt]

Good Luck

1-1 of 1