Reputation: 213
I have an issue in my SharePoint environment and I suspect that this code may be causing a memory leak. I pass a SPWeb object as by value parameter.
Does the SPWeb object get disposed correctly with this code?
public void DoSomething(SPWeb web)
{
// code here
}
public void mainProgram()
{
using (SPWeb web = site.OpenWeb())
{
DoSomething(web);
//another code here
}
}
Upvotes: 2
Views: 519
Reputation: 351
This will not cause a memory leak, but if you want to be sure run SPDisposeCheck tool on your code. HTH Vojta
Upvotes: 2