If you would like to work with SharePoint, first at all, you should read this post. It describes how to dispose SharePoint objects.
In the post you can find this:
public void RootWebBestPractice() { // New SPSite. using (SPSite siteCollection = new SPSite("http://moss")) { SPWeb rootWeb1 = siteCollection.RootWeb; // No explicit rootWeb1 dispose required. } // siteCollection automatically disposed by implementing using(). // rootWeb1 will be Disposed by SPSite. // SPContext and SPControl SPWeb rootWeb2 = SPContext.Current.Site.RootWeb; // Also would apply to SPControl.GetContextSite(Context); // No explicit rootWeb2 dispose required because it's obtained from SPContext.Current.Site. }