<?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: Avoiding Memory Leaks With NServiceBus And Your Own Castle Windsor Instance</title>
	<atom:link href="http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/feed/" rel="self" type="application/rss+xml" />
	<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/</link>
	<description>Trying to walk that thin line between intelligence and ignorance</description>
	<lastBuildDate>Wed, 08 Sep 2010 21:03:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Advanced Castle Windsor – generic typed factories, auto-release and more - Krzysztof Kozmic - Devlicio.us - Just the Tasty Bits</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-31543</link>
		<dc:creator>Advanced Castle Windsor – generic typed factories, auto-release and more - Krzysztof Kozmic - Devlicio.us - Just the Tasty Bits</dc:creator>
		<pubDate>Thu, 11 Mar 2010 20:14:47 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-31543</guid>
		<description>[...] actually, and while I have precisely zero knowledge of NServiceBus, I think it could be used to fix the issue Davy discussed, without having to mess with release policy.  Posted 03-11-2010 9:13 PM by Krzysztof Koźmic Filed [...]</description>
		<content:encoded><![CDATA[<p>[...] actually, and while I have precisely zero knowledge of NServiceBus, I think it could be used to fix the issue Davy discussed, without having to mess with release policy.  Posted 03-11-2010 9:13 PM by Krzysztof Koźmic Filed [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29435</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Mon, 22 Feb 2010 10:29:26 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29435</guid>
		<description>@Krzysztof

i&#039;m not the one you need to convince here... most people think i take IDisposable and memory management in general too seriously ;)
(coincidentally, these are the same people who don&#039;t believe me when i say we always disable application pool recycling and _don&#039;t_ run into issues with it... go figure ;))</description>
		<content:encoded><![CDATA[<p>@Krzysztof</p>
<p>i&#8217;m not the one you need to convince here&#8230; most people think i take IDisposable and memory management in general too seriously <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
(coincidentally, these are the same people who don&#8217;t believe me when i say we always disable application pool recycling and _don&#8217;t_ run into issues with it&#8230; go figure <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Udi Dahan</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29434</link>
		<dc:creator>Udi Dahan</dc:creator>
		<pubDate>Mon, 22 Feb 2010 10:28:43 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29434</guid>
		<description>You&#039;re right that NServiceBus shouldn&#039;t change the release policy of the container that is passed in - this will be fixed in the 2.0 RTM.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right that NServiceBus shouldn&#8217;t change the release policy of the container that is passed in &#8211; this will be fixed in the 2.0 RTM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krzysztof Koźmic</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29421</link>
		<dc:creator>Krzysztof Koźmic</dc:creator>
		<pubDate>Mon, 22 Feb 2010 09:56:32 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29421</guid>
		<description>@Davy

It obviously is not.
NTRP fixes symptoms - not causes.
You may use no IoC Container at all, and still NSB not releasing it&#039;s components means you will have leaks nonetheless. You may have handlers that obtain database connection. If you don&#039;t release them, they won&#039;t release the connection. They may have finalizers but before finalizers run, you may already be out of connections and your application may die (yes - there are more problems here than these related to NSB, but it&#039;s just an example ;) ).

And that problem would touch not only Windsor. AutoFac also tracks some transient components, StructureMap does so with nested containers... dunno about the rest.</description>
		<content:encoded><![CDATA[<p>@Davy</p>
<p>It obviously is not.<br />
NTRP fixes symptoms &#8211; not causes.<br />
You may use no IoC Container at all, and still NSB not releasing it&#8217;s components means you will have leaks nonetheless. You may have handlers that obtain database connection. If you don&#8217;t release them, they won&#8217;t release the connection. They may have finalizers but before finalizers run, you may already be out of connections and your application may die (yes &#8211; there are more problems here than these related to NSB, but it&#8217;s just an example <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).</p>
<p>And that problem would touch not only Windsor. AutoFac also tracks some transient components, StructureMap does so with nested containers&#8230; dunno about the rest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29415</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Mon, 22 Feb 2010 09:15:54 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29415</guid>
		<description>@Krzysztof 

you&#039;d have to ask Udi that... though i suspect he&#039;ll tell you that the NoTrackingReleasePolicy is already &quot;good enough&quot;</description>
		<content:encoded><![CDATA[<p>@Krzysztof </p>
<p>you&#8217;d have to ask Udi that&#8230; though i suspect he&#8217;ll tell you that the NoTrackingReleasePolicy is already &#8220;good enough&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krzysztof Koźmic</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29414</link>
		<dc:creator>Krzysztof Koźmic</dc:creator>
		<pubDate>Mon, 22 Feb 2010 09:14:12 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29414</guid>
		<description>that is interesting.

Can&#039;t NServiceBus limit scope of container by using nested container per unit of work?
This may be my motivation to finally take a look at NSB, which I&#039;ve been meaning to do for quite some time.</description>
		<content:encoded><![CDATA[<p>that is interesting.</p>
<p>Can&#8217;t NServiceBus limit scope of container by using nested container per unit of work?<br />
This may be my motivation to finally take a look at NSB, which I&#8217;ve been meaning to do for quite some time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Artur Dorochowicz</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29350</link>
		<dc:creator>Artur Dorochowicz</dc:creator>
		<pubDate>Sun, 21 Feb 2010 20:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29350</guid>
		<description>I totally agree, it should not change the container handed to it.

You have quite a neat solution here. So far I went along with NSB&#039;s behaviour in my app, because I don&#039;t have my own code that would rely on this feature of Windsor, but I think I will switch to your solution - even if I don&#039;t rely on it one never knows if some other stuff (like facilities) also does not. 
Thanks for sharing it.

BTW I would change the check to catch NSB namespace only:
 if (!instance.GetType().FullName.StartsWith(&quot;NServiceBus.&quot;))</description>
		<content:encoded><![CDATA[<p>I totally agree, it should not change the container handed to it.</p>
<p>You have quite a neat solution here. So far I went along with NSB&#8217;s behaviour in my app, because I don&#8217;t have my own code that would rely on this feature of Windsor, but I think I will switch to your solution &#8211; even if I don&#8217;t rely on it one never knows if some other stuff (like facilities) also does not.<br />
Thanks for sharing it.</p>
<p>BTW I would change the check to catch NSB namespace only:<br />
 if (!instance.GetType().FullName.StartsWith(&#8220;NServiceBus.&#8221;))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29348</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Sun, 21 Feb 2010 20:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29348</guid>
		<description>huh, that&#039;s weird... i tested it before using my own release policy and the kernel&#039;s ReleasePolicy was still set to the default after configuring NSB.  I&#039;m probably still using a build from right before the NoTrackingReleasePolicy-change was made to NSB...

Either way, the approach above will still work, as long as you overwrite the ReleasePolicy _after_ you configure NSB.

I do think the act of changing the ReleasePolicy of a passed-in container to the NoTrackingReleasePolicy is wrong... the consequences it can have on existing code can be pretty big and people really need to be aware of this</description>
		<content:encoded><![CDATA[<p>huh, that&#8217;s weird&#8230; i tested it before using my own release policy and the kernel&#8217;s ReleasePolicy was still set to the default after configuring NSB.  I&#8217;m probably still using a build from right before the NoTrackingReleasePolicy-change was made to NSB&#8230;</p>
<p>Either way, the approach above will still work, as long as you overwrite the ReleasePolicy _after_ you configure NSB.</p>
<p>I do think the act of changing the ReleasePolicy of a passed-in container to the NoTrackingReleasePolicy is wrong&#8230; the consequences it can have on existing code can be pretty big and people really need to be aware of this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Artur Dorochowicz</title>
		<link>http://davybrion.com/blog/2010/02/avoiding-memory-leaks-with-nservicebus-and-your-own-castle-windsor-instance/comment-page-1/#comment-29347</link>
		<dc:creator>Artur Dorochowicz</dc:creator>
		<pubDate>Sun, 21 Feb 2010 20:25:11 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=2268#comment-29347</guid>
		<description>&lt;cite&gt;Now, when you configure NServiceBus and pass it your instance of Castle Windsor, it obviously doesn’t change the ReleasePolicy like it does when it creates its own instance of Castle Windsor.&lt;/cite&gt;

Well, it actually does. The relevant part in WindsorObjectBuilder class is 

&lt;cite&gt;
        public WindsorObjectBuilder(IWindsorContainer container)
        {
            Container = container;
            container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy();
        }
&lt;/cite&gt;

and it is called from ConfigureWindsorBuilder

&lt;cite&gt;
        public static Configure CastleWindsorBuilder(this Configure config, IWindsorContainer container)
        {
            ConfigureCommon.With(config, new WindsorObjectBuilder(container));

            return config;
        } 

&lt;/cite&gt;</description>
		<content:encoded><![CDATA[<p><cite>Now, when you configure NServiceBus and pass it your instance of Castle Windsor, it obviously doesn’t change the ReleasePolicy like it does when it creates its own instance of Castle Windsor.</cite></p>
<p>Well, it actually does. The relevant part in WindsorObjectBuilder class is </p>
<p><cite><br />
        public WindsorObjectBuilder(IWindsorContainer container)<br />
        {<br />
            Container = container;<br />
            container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy();<br />
        }<br />
</cite></p>
<p>and it is called from ConfigureWindsorBuilder</p>
<p><cite><br />
        public static Configure CastleWindsorBuilder(this Configure config, IWindsorContainer container)<br />
        {<br />
            ConfigureCommon.With(config, new WindsorObjectBuilder(container));</p>
<p>            return config;<br />
        } </p>
<p></cite></p>
]]></content:encoded>
	</item>
</channel>
</rss>
