Thank you Jeremy. Y'know the reason I put this blogpost up there was because I felt there is an inaccuracy in Roger's post and the MSDN articles that Mika pointed us to. In short, they over-emphasize SPWeb.Dispose() which was true for WSS2, but for WSS3 it is unecessary.
I'll explain with an example.
Examine this code here -->
void SPListBreakRoleInheritanceLeak()
{
using (SPSite siteCollection = new SPSite("
http://moss"))
{
using (SPWeb web = siteCollection.OpenWeb())
{
SPList list = web.Lists["ListName"];
list.BreakRoleInheritance(true);
// SPWeb list.ParentWeb leaked here, requires call to list.ParentWeb.Dispose()
} // SPWeb object outerWeb.Dispose() automatically called
} // SPSite object siteCollection.Dispose() automatically called
}
.. Now Roger says that ..
SPWeb list.ParentWeb leaked here, requires call to list.ParentWeb.Dispose()
.. That's not true. Calling SPSite.Dispose (which immediately ensues as the next using block "}"), will call ParentWeb.Dispose().
So in reality, both the MSDN articles, and Roger's blogpost have unecessary emphasis on calling SPWeb.Dispose() .. which IMO is unecessary.
Sahil