<?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: Do Anonymous Methods Prevent Declaring Types from Being GC&#8217;d?</title>
	<atom:link href="http://lostechies.com/rayhouston/2008/05/22/do-anonymous-methods-prevent-declaring-types-from-being-gc-d/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/rayhouston/2008/05/22/do-anonymous-methods-prevent-declaring-types-from-being-gc-d/</link>
	<description></description>
	<lastBuildDate>Tue, 02 Apr 2013 20:36:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Scott Bellware</title>
		<link>http://lostechies.com/rayhouston/2008/05/22/do-anonymous-methods-prevent-declaring-types-from-being-gc-d/#comment-65</link>
		<dc:creator>Scott Bellware</dc:creator>
		<pubDate>Fri, 23 May 2008 18:21:36 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rhouston/archive/2008/05/21/do-anonymous-methods-prevent-declaring-types-from-being-gc-d.aspx#comment-65</guid>
		<description>It&#039;s not actually a memory leak.  It&#039;s because the lambda returned from GetFunc2 refers to a field of the outer object.  That field then needs to be lifted (see: lambda lifting).

When this happens, it&#039;s as if a LineItem object was given an implicit reference to its Order object and then the LineItem got passed somewhere else.

As long as you have an uncollected instance of the lambda (which is a closure) that refers to data from outside it&#039;s own scope (the instance filed), that outer scope is kept alive so that the lambda can continue to have access to its lifted data.
</description>
		<content:encoded><![CDATA[<p>It&#8217;s not actually a memory leak.  It&#8217;s because the lambda returned from GetFunc2 refers to a field of the outer object.  That field then needs to be lifted (see: lambda lifting).</p>
<p>When this happens, it&#8217;s as if a LineItem object was given an implicit reference to its Order object and then the LineItem got passed somewhere else.</p>
<p>As long as you have an uncollected instance of the lambda (which is a closure) that refers to data from outside it&#8217;s own scope (the instance filed), that outer scope is kept alive so that the lambda can continue to have access to its lifted data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Wiebe</title>
		<link>http://lostechies.com/rayhouston/2008/05/22/do-anonymous-methods-prevent-declaring-types-from-being-gc-d/#comment-64</link>
		<dc:creator>Jeremy Wiebe</dc:creator>
		<pubDate>Thu, 22 May 2008 23:21:11 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rhouston/archive/2008/05/21/do-anonymous-methods-prevent-declaring-types-from-being-gc-d.aspx#comment-64</guid>
		<description>I _believe_ that if you look at your code in Reflector you&#039;d see that the anonymous delegate actually becomes a method on an inner class of your declaring type.  This would make sense then that the declaring class is not GC&#039;d.

One side note, I think the test would be more explicit if you forced a GC instead of doing a Thread.Sleep().   My $0.02.  :-)</description>
		<content:encoded><![CDATA[<p>I _believe_ that if you look at your code in Reflector you&#8217;d see that the anonymous delegate actually becomes a method on an inner class of your declaring type.  This would make sense then that the declaring class is not GC&#8217;d.</p>
<p>One side note, I think the test would be more explicit if you forced a GC instead of doing a Thread.Sleep().   My $0.02.  <img src='http://lostechies.com/rayhouston/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jimmy Bogard</title>
		<link>http://lostechies.com/rayhouston/2008/05/22/do-anonymous-methods-prevent-declaring-types-from-being-gc-d/#comment-63</link>
		<dc:creator>Jimmy Bogard</dc:creator>
		<pubDate>Thu, 22 May 2008 02:20:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rhouston/archive/2008/05/21/do-anonymous-methods-prevent-declaring-types-from-being-gc-d.aspx#comment-63</guid>
		<description>Hmmm...I think this has something to do with Closures.</description>
		<content:encoded><![CDATA[<p>Hmmm&#8230;I think this has something to do with Closures.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
