<?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: Memory Leaks: Part II &#8211; variables scope leak</title>
	<atom:link href="http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=memory-leaks-part-ii-variables-scope-leak</link>
	<description>Mike Schierberl&#039;s thoughts on software development</description>
	<lastBuildDate>Wed, 06 Jun 2012 00:33:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: mike</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-795</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Tue, 11 Oct 2011 17:33:34 +0000</pubDate>
		<guid isPermaLink="false">#comment-795</guid>
		<description>It&#039;s been a few years since I&#039;ve looked at this, but I do remember that the behavior described in the post was addressed and fixed with one of the ACF 8 updaters.  However, the updater did not fix the problems that we had observed in our production environment at Planitax.

I also recall that the problem was limited to ACF, and did not appear in BD or Railo, unfortunately at the time those platforms weren&#039;t options that we could have considered.</description>
		<content:encoded><![CDATA[<p>It&#8217;s been a few years since I&#8217;ve looked at this, but I do remember that the behavior described in the post was addressed and fixed with one of the ACF 8 updaters.  However, the updater did not fix the problems that we had observed in our production environment at Planitax.</p>
<p>I also recall that the problem was limited to ACF, and did not appear in BD or Railo, unfortunately at the time those platforms weren&#8217;t options that we could have considered.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gert Franz</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-794</link>
		<dc:creator>Gert Franz</dc:creator>
		<pubDate>Tue, 11 Oct 2011 09:04:40 +0000</pubDate>
		<guid isPermaLink="false">#comment-794</guid>
		<description>Quick question,

Have you checked the results on some later versions of ACF as well, or perhaps even Railo? I just thought, that if you may still have the setup somewhere, you could verify it.

Gert</description>
		<content:encoded><![CDATA[<p>Quick question,</p>
<p>Have you checked the results on some later versions of ACF as well, or perhaps even Railo? I just thought, that if you may still have the setup somewhere, you could verify it.</p>
<p>Gert</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrTroy</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-63</link>
		<dc:creator>MrTroy</dc:creator>
		<pubDate>Fri, 20 Jul 2007 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-63</guid>
		<description>I had a similar situation and found that if you do not put output=false on your cffunction tag, not just on your cfcomponent tag, you will experience memory leaks. I haven&#039;t used a profiler to see exactly what is being leaked, but just an FYI to anyone struggling with memory leaks.</description>
		<content:encoded><![CDATA[<p>I had a similar situation and found that if you do not put output=false on your cffunction tag, not just on your cfcomponent tag, you will experience memory leaks. I haven&#8217;t used a profiler to see exactly what is being leaked, but just an FYI to anyone struggling with memory leaks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Douglas Boberg</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-62</link>
		<dc:creator>Douglas Boberg</dc:creator>
		<pubDate>Mon, 13 Nov 2006 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-62</guid>
		<description>Mike, these are EXCELLENT postings.

I think there may be something else going on here.  I have reproduced your Part II test, and initially I saw the same results in the JRockit Memory Leak Detector that you&#039;ve shown.  But then, something weird happened.  Let me explain:


Part II in CFMX 6,1,0,63958:

In an attempt to &#039;solve&#039; the issue, I went through a variety of modifications to your code.  For example, in the doSomething() function I created a locally scoped &#039;holder&#039; variable and used that to create the object before appending to the return array:

&lt;cfset var tmpHolder = &quot;&quot; /&gt;

&lt;cfloop from=&quot;1&quot; to=&quot;100&quot; index=&quot;idx&quot;&gt;
	&lt;cfset tmpHolder=createObject(&quot;component&quot;,&quot;testChild&quot;).init() /&gt;
	&lt;cfset arrayAppend(arrayToReturn,tmpHolder) /&gt;
&lt;/cfloop&gt;


Also, as you can see in the code above I created a secondary CFC (testChild).  This made it clearer for me in the Leak Detector screen to see the separation of the test.cfc and its loop-of-100 spawn.  The testChild CFC contains only one function, an init() that simply returns THIS.


Neither of these did anything to your results.  I still received the exact same 100 lingering child elements you&#039;ve demonstrated.  To be honest, I was hoping that the local &#039;tmpHolder&#039; would have helped... somehow.


Here&#039;s where it gets weird.


I restarted the CF service and the Leak Detector and tested a slightly different situation.  I created a new CFM page, &quot;testOther.cfm&quot; that contained only one line of code: 

&lt;cfoutput&gt;#now()#&lt;/cfoutput&gt;

Then, I loaded the new testOther.cfm in a browser then immediately loaded the original test.cfm.  The results were very different.  This time, 100 testChild elements cleared up completely!

So I tried again... this time I loaded the original test.cfm FIRST; then the testOther.cfm.  The elements stayed in memory again, not clearing until the Application expired.

I did these two tests about a dozen times (letting the Application exipre between) and each time if I loaded &quot;testOther.cfm&quot; first, the testChild elements cleared; and when I loaded your &quot;test.cfm&quot; first, the testChild elements stayed as in your example.  I tested both sequences with single page loads, with multiple page loads, and mixed loads of both templates.  The results were the same.... depending on which template was loaded first caused different outcomes of the scenario.

???

- Are we 100% confident that the Leak Detector is showing the correct data?

- Is there a possibility that the CF caching Steven Erat and Sean Corfield mentioned is showing us inconclusive results in the Leak Detector?

- If we assume that this code is &#039;leaky&#039; all of the time, what could be hiding the leak during these other tests?

-If we assume that the code is never &#039;leaky&#039;, what are we viewing that makes it seem broken?</description>
		<content:encoded><![CDATA[<p>Mike, these are EXCELLENT postings.</p>
<p>I think there may be something else going on here.  I have reproduced your Part II test, and initially I saw the same results in the JRockit Memory Leak Detector that you&#8217;ve shown.  But then, something weird happened.  Let me explain:</p>
<p>Part II in CFMX 6,1,0,63958:</p>
<p>In an attempt to &#8216;solve&#8217; the issue, I went through a variety of modifications to your code.  For example, in the doSomething() function I created a locally scoped &#8216;holder&#8217; variable and used that to create the object before appending to the return array:</p>
<p>&lt;cfset var tmpHolder = &quot;&quot; /&gt;</p>
<p>&lt;cfloop from=&quot;1&quot; to=&quot;100&quot; index=&quot;idx&quot;&gt;<br />
	&lt;cfset tmpHolder=createObject(&quot;component&quot;,&quot;testChild&quot;).init() /&gt;<br />
	&lt;cfset arrayAppend(arrayToReturn,tmpHolder) /&gt;<br />
&lt;/cfloop&gt;</p>
<p>Also, as you can see in the code above I created a secondary CFC (testChild).  This made it clearer for me in the Leak Detector screen to see the separation of the test.cfc and its loop-of-100 spawn.  The testChild CFC contains only one function, an init() that simply returns THIS.</p>
<p>Neither of these did anything to your results.  I still received the exact same 100 lingering child elements you&#8217;ve demonstrated.  To be honest, I was hoping that the local &#8216;tmpHolder&#8217; would have helped&#8230; somehow.</p>
<p>Here&#8217;s where it gets weird.</p>
<p>I restarted the CF service and the Leak Detector and tested a slightly different situation.  I created a new CFM page, &quot;testOther.cfm&quot; that contained only one line of code: </p>
<p>&lt;cfoutput&gt;#now()#&lt;/cfoutput&gt;</p>
<p>Then, I loaded the new testOther.cfm in a browser then immediately loaded the original test.cfm.  The results were very different.  This time, 100 testChild elements cleared up completely!</p>
<p>So I tried again&#8230; this time I loaded the original test.cfm FIRST; then the testOther.cfm.  The elements stayed in memory again, not clearing until the Application expired.</p>
<p>I did these two tests about a dozen times (letting the Application exipre between) and each time if I loaded &quot;testOther.cfm&quot; first, the testChild elements cleared; and when I loaded your &quot;test.cfm&quot; first, the testChild elements stayed as in your example.  I tested both sequences with single page loads, with multiple page loads, and mixed loads of both templates.  The results were the same&#8230;. depending on which template was loaded first caused different outcomes of the scenario.</p>
<p>???</p>
<p>- Are we 100% confident that the Leak Detector is showing the correct data?</p>
<p>- Is there a possibility that the CF caching Steven Erat and Sean Corfield mentioned is showing us inconclusive results in the Leak Detector?</p>
<p>- If we assume that this code is &#8216;leaky&#8217; all of the time, what could be hiding the leak during these other tests?</p>
<p>-If we assume that the code is never &#8216;leaky&#8217;, what are we viewing that makes it seem broken?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Middleton</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-58</link>
		<dc:creator>Neil Middleton</dc:creator>
		<pubDate>Wed, 08 Nov 2006 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-58</guid>
		<description>I&#039;ve just run through Mike&#039;s description and replicated the problem perfectly. I started the test on my local server (which had around 80% free memory) and then created tens of thousands of objects as Mike described. Free memory then dropped to around 50% where it sat for the entire night (normally you would expect this to go back up after 20 minutes or so)

I&#039;m running CFMX7.0.1, Win2K3, SUN JVM 1.4.2_08</description>
		<content:encoded><![CDATA[<p>I&#8217;ve just run through Mike&#8217;s description and replicated the problem perfectly. I started the test on my local server (which had around 80% free memory) and then created tens of thousands of objects as Mike described. Free memory then dropped to around 50% where it sat for the entire night (normally you would expect this to go back up after 20 minutes or so)</p>
<p>I&#8217;m running CFMX7.0.1, Win2K3, SUN JVM 1.4.2_08</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russ Michaels</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-59</link>
		<dc:creator>Russ Michaels</dc:creator>
		<pubDate>Wed, 08 Nov 2006 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-59</guid>
		<description>The issue is a know issue to Sun and it logged in their VM bug tracker as a issue with garbage collection.</description>
		<content:encoded><![CDATA[<p>The issue is a know issue to Sun and it logged in their VM bug tracker as a issue with garbage collection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Schierberl</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-60</link>
		<dc:creator>Mike Schierberl</dc:creator>
		<pubDate>Wed, 08 Nov 2006 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-60</guid>
		<description>Russ-
Do you have a link to the issue in the Sun Bug Tracker?  I went down that path around 6 months ago, and identified 2 potential known issues that had been identified by Sun.  Both were fixed in the 1.5 release.  I have now tested the behavior on the following JVMs.

Sun 1.4.2_08
Sun 1.4.2_13
Sun 1.5.0_09
BEA 1.5.0_06

All produce virtually identical results.  In my opinion, this would eliminate the jvm version as a culprit, unless this is still an outstanding issue with Sun.</description>
		<content:encoded><![CDATA[<p>Russ-<br />
Do you have a link to the issue in the Sun Bug Tracker?  I went down that path around 6 months ago, and identified 2 potential known issues that had been identified by Sun.  Both were fixed in the 1.5 release.  I have now tested the behavior on the following JVMs.</p>
<p>Sun 1.4.2_08<br />
Sun 1.4.2_13<br />
Sun 1.5.0_09<br />
BEA 1.5.0_06</p>
<p>All produce virtually identical results.  In my opinion, this would eliminate the jvm version as a culprit, unless this is still an outstanding issue with Sun.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Archibald</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-61</link>
		<dc:creator>Ben Archibald</dc:creator>
		<pubDate>Wed, 08 Nov 2006 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-61</guid>
		<description>I concur.  I&#039;ve basically dismissed the JVM theory presented here and on some lists I participate in (although on those lists the JVM theory largely dismissed your report, sadly!).  I&#039;ve verified the same problems on 6.0, 6.1 (different JVM) and with a few swaps of JVM on 7.  

While it certainly good to remove a buggy JVM from the stack, I&#039;m fairly sure CF proper is the culprit.

Thanks for keeping on this Mike!</description>
		<content:encoded><![CDATA[<p>I concur.  I&#8217;ve basically dismissed the JVM theory presented here and on some lists I participate in (although on those lists the JVM theory largely dismissed your report, sadly!).  I&#8217;ve verified the same problems on 6.0, 6.1 (different JVM) and with a few swaps of JVM on 7.  </p>
<p>While it certainly good to remove a buggy JVM from the stack, I&#8217;m fairly sure CF proper is the culprit.</p>
<p>Thanks for keeping on this Mike!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russ Michaels</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-57</link>
		<dc:creator>Russ Michaels</dc:creator>
		<pubDate>Wed, 01 Nov 2006 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-57</guid>
		<description>Mike, there are known memory leak issues like this with, so I think it is a JVM problem and not a CF problem, as myself and several others were unable to replicate this problem.  I suggest you try a different JVM (like 1.4.2_12) and see what happens.</description>
		<content:encoded><![CDATA[<p>Mike, there are known memory leak issues like this with, so I think it is a JVM problem and not a CF problem, as myself and several others were unable to replicate this problem.  I suggest you try a different JVM (like 1.4.2_12) and see what happens.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Schierberl</title>
		<link>http://www.schierberl.com/blog/memory-leaks-part-ii-variables-scope-leak/#comment-56</link>
		<dc:creator>Mike Schierberl</dc:creator>
		<pubDate>Thu, 26 Oct 2006 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-56</guid>
		<description>Just to let everyone know, I posted another entry/demo that shows a better example of the memory leak that I encountered.  Take a look here.

http://www.schierberl.com/cfblog/index.cfm/2006/10/25/memoryLeaks_session

-Mike</description>
		<content:encoded><![CDATA[<p>Just to let everyone know, I posted another entry/demo that shows a better example of the memory leak that I encountered.  Take a look here.</p>
<p><a href="http://www.schierberl.com/cfblog/index.cfm/2006/10/25/memoryLeaks_session" rel="nofollow">http://www.schierberl.com/cfblog/index.cfm/2006/10/25/memoryLeaks_session</a></p>
<p>-Mike</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: enhanced

Served from: www.schierberl.com @ 2013-05-22 14:32:24 -->