<?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: .NET Garbage Collector making me batty, again</title>
	<atom:link href="http://www.thegatesofdawn.ca/wordpress/posts/2009/11/19/net-garbage-collector-making-me-batty-again/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thegatesofdawn.ca/wordpress/posts/2009/11/19/net-garbage-collector-making-me-batty-again/</link>
	<description>WARNING: This blog contains writings known to the state of California to cause cancer and birth defects or other reproductive harm.</description>
	<lastBuildDate>Fri, 30 Jul 2010 19:27:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: piper</title>
		<link>http://www.thegatesofdawn.ca/wordpress/posts/2009/11/19/net-garbage-collector-making-me-batty-again/comment-page-1/#comment-150563</link>
		<dc:creator>piper</dc:creator>
		<pubDate>Sat, 19 Dec 2009 01:55:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegatesofdawn.ca/wordpress/?p=501#comment-150563</guid>
		<description>You&#039;re probably right.  I&#039;m pretty sure the garbage collector wouldn&#039;t be examining the code to see what it does, or might do.

Anyway, it was a behaviour that caught me by surprise.  C++ certainly wouldn&#039;t do that.  In fact, it&#039;s a fairly common technique to create objects for the sole purpose of running their destructors at the end of the scope.  But they are not referenced at all after their creation.

For example, I have a class like that that I use to acquire a semaphore, which guarantees that no matter how we leave its scope (return, goto, exception, whatever), the semaphore will be released.  Foolproof, and no need for ugly try/catch blocks.</description>
		<content:encoded><![CDATA[<p>You&#8217;re probably right.  I&#8217;m pretty sure the garbage collector wouldn&#8217;t be examining the code to see what it does, or might do.</p>
<p>Anyway, it was a behaviour that caught me by surprise.  C++ certainly wouldn&#8217;t do that.  In fact, it&#8217;s a fairly common technique to create objects for the sole purpose of running their destructors at the end of the scope.  But they are not referenced at all after their creation.</p>
<p>For example, I have a class like that that I use to acquire a semaphore, which guarantees that no matter how we leave its scope (return, goto, exception, whatever), the semaphore will be released.  Foolproof, and no need for ugly try/catch blocks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthias</title>
		<link>http://www.thegatesofdawn.ca/wordpress/posts/2009/11/19/net-garbage-collector-making-me-batty-again/comment-page-1/#comment-150551</link>
		<dc:creator>matthias</dc:creator>
		<pubDate>Fri, 18 Dec 2009 20:22:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegatesofdawn.ca/wordpress/?p=501#comment-150551</guid>
		<description>Its probably not the garbage collector.
Probably the compiler reduces the scope of the object to only the region where it is accessed.  Which means, the reference to the object is gone before it actually &quot;went out of scopoe&quot;.  I had seen this type of thing back as far as 1990, where I saw that my compiled basic program didn&#039;t bother storing the result of a calculation because it knew it would never get referenced again.</description>
		<content:encoded><![CDATA[<p>Its probably not the garbage collector.<br />
Probably the compiler reduces the scope of the object to only the region where it is accessed.  Which means, the reference to the object is gone before it actually &#8220;went out of scopoe&#8221;.  I had seen this type of thing back as far as 1990, where I saw that my compiled basic program didn&#8217;t bother storing the result of a calculation because it knew it would never get referenced again.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
