bagus ilman
bagus ilman

Reputation: 213

Does passing SPWeb as a by value parameter cause a memory leak?

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

Answers (1)

Vojtech Nadvornik
Vojtech Nadvornik

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

Related Questions