Always dispose SPSite and SPWeb object

Try to dispose each of the object (SPSite and SPWeb) because these objects are 2MB is size, the best way to code is to use it in scopes for example

 

using (SPSite site=SPContext.Current.Site)

{

using (SPWeb web=site.OpenWeb())

{

// write your code

}

}

Advertisements