Should I call Dispose on SPWeb.ParentWeb?

I was coding away and wondered if I should call Dispose the parentWeb object below?

SPWeb parentWeb = web.ParentWeb;
parentWeb.Dispose(); //Should I?

I found some official guidance on this and thought I’d blog it here, partly to help jolt my memory later on.

The short answer is: No, calling Dispose() is not required on SPWeb.ParentWeb:

From MSDN (

“SPWeb.ParentWeb Property

Updated Guidance

An earlier version of this article recommended that the calling application should dispose of the SPWeb.ParentWeb. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework.”


Update: What about SPSite.RootWeb – should I call Dispose() on that? Official guidance (also in the above link) is: NO. Do not call SPSite.RootWeb.Dispose().

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in SharePoint 2010. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s