<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SPSherm.MyBlog &#187; Best Practice</title>
	<atom:link href="http://spsherm.uptempoconsulting.com/tag/best-practice/feed/" rel="self" type="application/rss+xml" />
	<link>http://spsherm.uptempoconsulting.com</link>
	<description>SharePoint, of course.</description>
	<lastBuildDate>Mon, 03 Oct 2011 03:01:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>MSDN Link: SharePoint Best Practices &#8211; Disposing WSS Objects</title>
		<link>http://spsherm.uptempoconsulting.com/2007/08/msdn-link-sharepoint-best-practices-disposing-wss-objects/</link>
		<comments>http://spsherm.uptempoconsulting.com/2007/08/msdn-link-sharepoint-best-practices-disposing-wss-objects/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 23:28:52 +0000</pubDate>
		<dc:creator>Sherman</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[SP2007]]></category>

		<guid isPermaLink="false">http://spsherm.uptempoconsulting.com/?p=40</guid>
		<description><![CDATA[ Might as well dive right in and make the inaugural posting useful&#8230;  Anyone who&#8217;s done some development work with SharePoint probably already knows about this article, but I wanted to place it here for reference: Best Practices: Using Disposable Windows SharePoint Services Objects Review the article very carefully&#8230; there are things we do often such [...]]]></description>
			<content:encoded><![CDATA[<p> <em>Might as well dive right in and make the inaugural posting useful&#8230;</em> </p>
<p>Anyone who&#8217;s done some development work with SharePoint probably already knows about this article, but I wanted to place it here for reference:</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/aa973248.aspx" target="_blank">Best Practices: Using Disposable Windows SharePoint Services Objects</a></p>
<p>Review the article very carefully&#8230; there are things we do often such as getting to an SPSite&#8217;s RootWeb, like this:</p>
<pre class="brush: csharp; light: true; title: ; notranslate">SPSite site = SPControl.GetContextSite(HttpContext.Current);
SPWeb rootWeb = site.RootWeb;</pre>
<p>In this case, it&#8217;s pretty obvious (based on the article) that we need to call:</p>
<pre class="brush: csharp; light: true; title: ; notranslate">rootWeb.Dispose();</pre>
<p>However, if you were to access a property like this:</p>
<pre class="brush: csharp; light: true; title: ; notranslate">string rootWebTitle = site.RootWeb.Title;</pre>
<p>the article states that you should call</p>
<pre class="brush: csharp; light: true; title: ; notranslate">site.RootWeb.Dispose();</pre>
<p>which is not obvious, in my opinion. So to keep/ensure your SharePoint site/application runs as smoothly as possible, clean up after yourself! </p>
<p>EDIT (September 2008):</p>
<p>This is kind of old news by now, but here is another article from Andrew Woodward (which references 3 articles other than MSDN). Worthy to note that we need to properly Close() all PublishingWeb objects as well.<br />
<a href="http://www.21apps.com/2008/02/sharepoint-ate-all-my-memory-dealing.html">http://www.21apps.com/2008/02/sharepoint-ate-all-my-memory-dealing.html</a></p>
<p>Roger Lamb&#8217;s blog has some really good examples. Also make sure to read the comments.<br />
<a href="http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx">http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx</a></p>
<p>Stefan Gossner gives a pretty good in-depth look at how memory is consumed.<br />
<a href="http://blogs.technet.com/stefan_gossner/archive/2007/11/26/dealing-with-memory-pressure-problems-in-moss-wss.aspx">http://blogs.technet.com/stefan_gossner/archive/2007/11/26/dealing-with-memory-pressure-problems-in-moss-wss.aspx</a></p>
<p>Finally, a post about application pool/worker process recycling and SharePoint.<br />
<a href="http://blogs.msdn.com/steveshe/archive/2007/12/17/overlapped-recycling-and-sharepoint-why-sharepoint-requires-it.aspx">http://blogs.msdn.com/steveshe/archive/2007/12/17/overlapped-recycling-and-sharepoint-why-sharepoint-requires-it.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://spsherm.uptempoconsulting.com/2007/08/msdn-link-sharepoint-best-practices-disposing-wss-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

