<?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"
	>
<channel>
	<title>Comments on: Passing parameters to a function called with setTimeout</title>
	<atom:link href="http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/</link>
	<description></description>
	<pubDate>Sun, 07 Sep 2008 22:27:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Jake</title>
		<link>http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-231</link>
		<dc:creator>Jake</dc:creator>
		<pubDate>Wed, 13 Aug 2008 03:47:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-231</guid>
		<description>Great tip!!  I've been looking for this solution for a while now.  Thanks!</description>
		<content:encoded><![CDATA[<p>Great tip!!  I&#8217;ve been looking for this solution for a while now.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-230</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 07 Aug 2008 08:25:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-230</guid>
		<description>This is great. I was getting rather frustrated with IE not accepting the 3rd parameter and could not find a way around it for my code. Now I dont have to.</description>
		<content:encoded><![CDATA[<p>This is great. I was getting rather frustrated with IE not accepting the 3rd parameter and could not find a way around it for my code. Now I dont have to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-193</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Wed, 07 Nov 2007 01:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-193</guid>
		<description>I was pulling my hair out.  The books seem to gloss over this like I should have known it and then go on to tell me some obscure thing I'll never use. I cannot thank you enough!</description>
		<content:encoded><![CDATA[<p>I was pulling my hair out.  The books seem to gloss over this like I should have known it and then go on to tell me some obscure thing I&#8217;ll never use. I cannot thank you enough!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bryan</title>
		<link>http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-189</link>
		<dc:creator>bryan</dc:creator>
		<pubDate>Wed, 31 Oct 2007 04:37:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-189</guid>
		<description>Thanks for that, J-P - I agree they seem to be rather a secret! I've added this into the news ticker and put up the &lt;a href="http://jquery.com/plugins/project/BBCnewsTicker rel="nofollow"&gt;new release&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for that, J-P - I agree they seem to be rather a secret! I&#8217;ve added this into the news ticker and put up the <a href="http://jquery.com/plugins/project/BBCnewsTicker rel="nofollow">new release</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J-P Stacey</title>
		<link>http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-186</link>
		<dc:creator>J-P Stacey</dc:creator>
		<pubDate>Mon, 29 Oct 2007 09:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/#comment-186</guid>
		<description>Closures are arguably the great secret of Javascript: the way variable scope stacks get frozen at the point of closure (and hence variables persist within the closure) is quite subtle and catches most out, including me!

Be warned that IEx has a garbage-collector subtlety, though; I think that if you reference a DOM variable in a Javascript closure, then the collection mechanism gets confused and it doesn't get trashed at the end of the request: eventually this becomes a memory leak. I think it's because DOM variables and internal JS variables get collected by two different collectors, and they don't communicate properly about what's no longer being used. 

I think you can fix this by setting the variable to null:

setTimeout(function(){myFunction(parameter); parameter = null},myTimeout);

This explicitly sets the garbage collection in motion.</description>
		<content:encoded><![CDATA[<p>Closures are arguably the great secret of Javascript: the way variable scope stacks get frozen at the point of closure (and hence variables persist within the closure) is quite subtle and catches most out, including me!</p>
<p>Be warned that IEx has a garbage-collector subtlety, though; I think that if you reference a DOM variable in a Javascript closure, then the collection mechanism gets confused and it doesn&#8217;t get trashed at the end of the request: eventually this becomes a memory leak. I think it&#8217;s because DOM variables and internal JS variables get collected by two different collectors, and they don&#8217;t communicate properly about what&#8217;s no longer being used. </p>
<p>I think you can fix this by setting the variable to null:</p>
<p>setTimeout(function(){myFunction(parameter); parameter = null},myTimeout);</p>
<p>This explicitly sets the garbage collection in motion.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.640 seconds -->
