<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: SPLimitedWebPartManager Memory Leak?</title>
	<atom:link href="http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/</link>
	<description>a discussion of technology and software development</description>
	<lastBuildDate>Fri, 20 Jan 2012 13:25:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: bryan</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-128</link>
		<dc:creator>bryan</dc:creator>
		<pubDate>Fri, 18 Nov 2011 13:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-128</guid>
		<description>Ah, you&#039;re right Adrian!  When I looked earlier I just took a quick glance at Dispose() and noticed it still wasn&#039;t cleaning it up, but you&#039;re right, it&#039;s no longer creating the instance inside of SPLimitedWebPartManager, instead it&#039;s point to an instance created by SPWebPartManager, and SPWebPartManager cleans up the SPWeb object.

Thanks for the correction!</description>
		<content:encoded><![CDATA[<p>Ah, you&#8217;re right Adrian!  When I looked earlier I just took a quick glance at Dispose() and noticed it still wasn&#8217;t cleaning it up, but you&#8217;re right, it&#8217;s no longer creating the instance inside of SPLimitedWebPartManager, instead it&#8217;s point to an instance created by SPWebPartManager, and SPWebPartManager cleans up the SPWeb object.</p>
<p>Thanks for the correction!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Iurov</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-126</link>
		<dc:creator>Adrian Iurov</dc:creator>
		<pubDate>Fri, 18 Nov 2011 13:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-126</guid>
		<description>From what I&#039;ve seen in the code, this is NOT a memory leak in SP2010.

These 2 fields are part of the SPLimitedWebPartManager class:

SPWeb m_web;
SPWebPartManager m_manager;

When Dispose() is called on SPLimitedWebPartManager, inside it calls m_manager.Dispose() which calls m_web.Dipose()

The m_web of the SPWebPartManager instance references the same SPWeb instance as the m_web of the SPLimitedWebPartManager instance.

In order to see that the 2 fields reference the same SPWeb instance, take a look at the way this m_web is opened inside SPWeb.GetLimitedWebPartManagerInternal. Later on is assigned to the m_web of a SPWebPartCollectionInitialState instance and in the end to the newly created SPWebPartManager instance.

It&#039;s a bit hard to follow, but if you need more details about the entire flow, I could provide them to you.</description>
		<content:encoded><![CDATA[<p>From what I&#8217;ve seen in the code, this is NOT a memory leak in SP2010.</p>
<p>These 2 fields are part of the SPLimitedWebPartManager class:</p>
<p>SPWeb m_web;<br />
SPWebPartManager m_manager;</p>
<p>When Dispose() is called on SPLimitedWebPartManager, inside it calls m_manager.Dispose() which calls m_web.Dipose()</p>
<p>The m_web of the SPWebPartManager instance references the same SPWeb instance as the m_web of the SPLimitedWebPartManager instance.</p>
<p>In order to see that the 2 fields reference the same SPWeb instance, take a look at the way this m_web is opened inside SPWeb.GetLimitedWebPartManagerInternal. Later on is assigned to the m_web of a SPWebPartCollectionInitialState instance and in the end to the newly created SPWebPartManager instance.</p>
<p>It&#8217;s a bit hard to follow, but if you need more details about the entire flow, I could provide them to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bryan</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-47</link>
		<dc:creator>bryan</dc:creator>
		<pubDate>Tue, 01 Nov 2011 15:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-47</guid>
		<description>From what I&#039;ve seen, yes.  I poked around in SPLimitedWebPartManager for 2010 and it still does not appear to close the SPWeb object that it opens up, so I would recommend still explicitly closing it.  If anyone has seen differently in 2010 let me know!</description>
		<content:encoded><![CDATA[<p>From what I&#8217;ve seen, yes.  I poked around in SPLimitedWebPartManager for 2010 and it still does not appear to close the SPWeb object that it opens up, so I would recommend still explicitly closing it.  If anyone has seen differently in 2010 let me know!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor Iliescu</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-46</link>
		<dc:creator>Tudor Iliescu</dc:creator>
		<pubDate>Tue, 01 Nov 2011 10:44:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-46</guid>
		<description>Very interesting! It the same in 2010?</description>
		<content:encoded><![CDATA[<p>Very interesting! It the same in 2010?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ArianaSype</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-8</link>
		<dc:creator>ArianaSype</dc:creator>
		<pubDate>Wed, 13 May 2009 12:18:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-8</guid>
		<description>Wow! Thank you very much! I always wanted to write in my site something like that</description>
		<content:encoded><![CDATA[<p>Wow! Thank you very much! I always wanted to write in my site something like that</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JessicaRich</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-7</link>
		<dc:creator>JessicaRich</dc:creator>
		<pubDate>Sun, 10 May 2009 17:20:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-7</guid>
		<description>Thanks for posting, definitely going to subscribe! See you on my reader.</description>
		<content:encoded><![CDATA[<p>Thanks for posting, definitely going to subscribe! See you on my reader.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Incanna</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-6</link>
		<dc:creator>Incanna</dc:creator>
		<pubDate>Fri, 08 May 2009 05:37:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-6</guid>
		<description>ehh. interesting..</description>
		<content:encoded><![CDATA[<p>ehh. interesting..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-5</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Wed, 24 Oct 2007 12:38:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-5</guid>
		<description>The difference is that the web part manager is not using your w instance, it creates its own instance on the following line:

SPWeb web = this.Site.OpenWeb();

In your example you actually have 2 instances of SPWeb, you have your instance &quot;w&quot;, and then there is an instance encapsulated in the web part manager &quot;web&quot;.  The web part manager should dispose of the &quot;web&quot; instance, not your &quot;w&quot; instance.</description>
		<content:encoded><![CDATA[<p>The difference is that the web part manager is not using your w instance, it creates its own instance on the following line:</p>
<p>SPWeb web = this.Site.OpenWeb();</p>
<p>In your example you actually have 2 instances of SPWeb, you have your instance &#8220;w&#8221;, and then there is an instance encapsulated in the web part manager &#8220;web&#8221;.  The web part manager should dispose of the &#8220;web&#8221; instance, not your &#8220;w&#8221; instance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shai</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-4</link>
		<dc:creator>Shai</dc:creator>
		<pubDate>Wed, 24 Oct 2007 11:07:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-4</guid>
		<description>Hi,
I fail to understand why you feel that disposing of the web part manager should also dispose its owner web?

for instance, if you have code like this:
spweb w = .....
SPLimitedWebPartManager mgr = w.OpenFile(&quot;...&quot;).GetLimitedWebPartManager(...);
mgr.AddWebPart(...);
mgr.Dispose();

w.Title += &quot; Done!&quot;;
w.Update();
w.Dispose();

See, I continue to work on the web object after disposing of the limited web part manager... It would be a bug if my w.TItle update will fail... no?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I fail to understand why you feel that disposing of the web part manager should also dispose its owner web?</p>
<p>for instance, if you have code like this:<br />
spweb w = &#8230;..<br />
SPLimitedWebPartManager mgr = w.OpenFile(&#8220;&#8230;&#8221;).GetLimitedWebPartManager(&#8230;);<br />
mgr.AddWebPart(&#8230;);<br />
mgr.Dispose();</p>
<p>w.Title += &#8221; Done!&#8221;;<br />
w.Update();<br />
w.Dispose();</p>
<p>See, I continue to work on the web object after disposing of the limited web part manager&#8230; It would be a bug if my w.TItle update will fail&#8230; no?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter {faa780ce-0f0a-4c28-81d2-3667b71287fd}</title>
		<link>http://www.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-3</link>
		<dc:creator>Peter {faa780ce-0f0a-4c28-81d2-3667b71287fd}</dc:creator>
		<pubDate>Fri, 28 Sep 2007 19:15:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ofonesandzeros.com/2007/06/05/splimitedwebpartmanager-memory-leak/#comment-3</guid>
		<description>Yes, this is exactly what I saw. It didn&#039;t surprise me at all when I got my &quot;outofmemoryexception&quot;; I already had a healthy fear of SharePoint. :)</description>
		<content:encoded><![CDATA[<p>Yes, this is exactly what I saw. It didn&#8217;t surprise me at all when I got my &#8220;outofmemoryexception&#8221;; I already had a healthy fear of SharePoint. <img src="http://dfcv747gi313t.cloudfront.net/wp-includes/images/smilies/icon_smile.gif?9d7bd4" alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Database Caching 1/5 queries in 0.008 seconds using disk: basic
Object Caching 340/344 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: dfcv747gi313t.cloudfront.net

Served from: www.ofonesandzeros.com @ 2012-02-05 13:15:53 -->
