<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Kick starting the garbage collector in Actionscript 3 with AIR</title>
	<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/</link>
	<description>Hacking away at UI development</description>
	<pubDate>Fri, 12 Mar 2010 12:22:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Tom Mason</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-19041</link>
		<dc:creator>Tom Mason</dc:creator>
		<pubDate>Thu, 21 Jan 2010 14:50:54 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-19041</guid>
		<description>Based on my own experience with AS3 memory management, I also have started pooling my display objects to keep memory usage small and efficient.  However, I've recently run into a bug in AIR with pooling MovieClips.

If you have a MovieClip with multiple frames representing different states for a model object, and you grab an instance from the pool, set its frame, show it, then put it back in the pool, and repeat, you'll see that the visual state of the MovieClip does not actually change when gotoAndStop is called.  The currentFrame property changes, but the MovieClip gets "stuck" in the same visual state the whole time.

I created a simple test project that exhibits the problem here:

http://www.gabob.com/AirBug.zip

After unzipping, set your workspace in Flex Builder to the flex folder.  Then you can run the flash and air versions.  The flash version works fine, but the air version only shows green squares, even though the frame is switched to blue sometimes.</description>
		<content:encoded><![CDATA[<p>Based on my own experience with AS3 memory management, I also have started pooling my display objects to keep memory usage small and efficient.  However, I&#8217;ve recently run into a bug in AIR with pooling MovieClips.</p>
<p>If you have a MovieClip with multiple frames representing different states for a model object, and you grab an instance from the pool, set its frame, show it, then put it back in the pool, and repeat, you&#8217;ll see that the visual state of the MovieClip does not actually change when gotoAndStop is called.  The currentFrame property changes, but the MovieClip gets &#8220;stuck&#8221; in the same visual state the whole time.</p>
<p>I created a simple test project that exhibits the problem here:</p>
<p><a href="http://www.gabob.com/AirBug.zip" rel="nofollow">http://www.gabob.com/AirBug.zip</a></p>
<p>After unzipping, set your workspace in Flex Builder to the flex folder.  Then you can run the flash and air versions.  The flash version works fine, but the air version only shows green squares, even though the frame is switched to blue sometimes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: So you have memory problems in your Flex application? &#171; Flex 4 Examples</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-15763</link>
		<dc:creator>So you have memory problems in your Flex application? &#171; Flex 4 Examples</dc:creator>
		<pubDate>Thu, 03 Sep 2009 16:58:49 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-15763</guid>
		<description>[...] Sean Christmann: http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Sean Christmann: <a href="http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/" rel="nofollow">http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Noble</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-15755</link>
		<dc:creator>Josh Noble</dc:creator>
		<pubDate>Thu, 03 Sep 2009 14:06:23 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-15755</guid>
		<description>This was super useful in a recent project I was working on, many thanks for putting this together.</description>
		<content:encoded><![CDATA[<p>This was super useful in a recent project I was working on, many thanks for putting this together.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: theRemix</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-15707</link>
		<dc:creator>theRemix</dc:creator>
		<pubDate>Tue, 01 Sep 2009 20:26:26 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-15707</guid>
		<description>interesting...
i recently found an awesome library that helps with these issues, CASAlib http://casalib.org/ i don't know if you have ever heard of it, it works wonders!
you just make your CasaSprites and destroy() or removeAndDestroyChildren() recursively and just let the GC do it's job automagically, you don't need to force System.gc() unless you want to for debugging and proof.
hth.</description>
		<content:encoded><![CDATA[<p>interesting&#8230;<br />
i recently found an awesome library that helps with these issues, CASAlib <a href="http://casalib.org/" rel="nofollow">http://casalib.org/</a> i don&#8217;t know if you have ever heard of it, it works wonders!<br />
you just make your CasaSprites and destroy() or removeAndDestroyChildren() recursively and just let the GC do it&#8217;s job automagically, you don&#8217;t need to force System.gc() unless you want to for debugging and proof.<br />
hth.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharad Joshi</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-13946</link>
		<dc:creator>Sharad Joshi</dc:creator>
		<pubDate>Wed, 01 Jul 2009 06:21:26 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-13946</guid>
		<description>Great article. Explains a lot of things that I have been facing. Thank you for sharing.

Can you please throw some light on how "Adobe took care of the first problem.. ". Is it available in FP10 or as a patch to FP9?</description>
		<content:encoded><![CDATA[<p>Great article. Explains a lot of things that I have been facing. Thank you for sharing.</p>
<p>Can you please throw some light on how &#8220;Adobe took care of the first problem.. &#8220;. Is it available in FP10 or as a patch to FP9?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thoughts &#38; Code</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-13596</link>
		<dc:creator>Thoughts &#38; Code</dc:creator>
		<pubDate>Wed, 24 Jun 2009 13:22:40 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-13596</guid>
		<description>[...] http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href="http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/" rel="nofollow">http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hadi</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-11964</link>
		<dc:creator>Hadi</dc:creator>
		<pubDate>Sat, 16 May 2009 16:48:50 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-11964</guid>
		<description>nicely said, I really needed this, you save me :) Thanks a lot.</description>
		<content:encoded><![CDATA[<p>nicely said, I really needed this, you save me <img src='http://www.craftymind.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manfred Karrer</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-6220</link>
		<dc:creator>Manfred Karrer</dc:creator>
		<pubDate>Sat, 13 Dec 2008 17:02:00 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-6220</guid>
		<description>we are working on a huge web-application with very frequent xml data loading (i know amf would be much better) and we fighting with a serious memory leak. the app starts with 150mb and grows in 10 hours up to 300 mb. we already tried out a lot of different approaches and at the moment it seems that object pooling is one of the most promising techniques to reduce memory consumption. 
i am not sure of some issues regarding the fragmentation of memory.
when the flashplayer demands more memory from the os it gets chunks with 4 kb size. (see: http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html) These chunks are divided into same size pieces like 32 byte blocks.
I assume that theses blocks are always a number based on the power of 2 (4,16,32,...)? so there are 13 (1+2^12=4096) possible “categories” of chunks. One with only 1 byte blocks, one with 2 byte blocks, one with 4 byte blocks and so on. the flash types uint, int and Number uses 4 byte, but how is it with Stings, and Objects? I guess Strings uses 8 bit (UTF8). But how are objects and class definitions handled? Do strings always use chunks with 1 byte blocks or do they divide them up to the next highest block size depending on the length of the string? If a string has 14 chars does it then use a chunk with block size 16?
The reason for my questions is that we have started using object pooling with a few objects which are created by parsing xml data via e4x and we have got 50% less memory leakage. We have to investigate this further but I am wondering if the memory management in the flashplayer could cause our leaks?
As far as we have discovered yet e4x creates a lot of objects and strings internally which needs memory to be allocated and should be freed after parsing, but it seems that this is not cleaned up completely.
Does anyone have more information about this topic?</description>
		<content:encoded><![CDATA[<p>we are working on a huge web-application with very frequent xml data loading (i know amf would be much better) and we fighting with a serious memory leak. the app starts with 150mb and grows in 10 hours up to 300 mb. we already tried out a lot of different approaches and at the moment it seems that object pooling is one of the most promising techniques to reduce memory consumption.<br />
i am not sure of some issues regarding the fragmentation of memory.<br />
when the flashplayer demands more memory from the os it gets chunks with 4 kb size. (see: <a href="http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html" rel="nofollow">http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html</a>) These chunks are divided into same size pieces like 32 byte blocks.<br />
I assume that theses blocks are always a number based on the power of 2 (4,16,32,&#8230;)? so there are 13 (1+2^12=4096) possible “categories” of chunks. One with only 1 byte blocks, one with 2 byte blocks, one with 4 byte blocks and so on. the flash types uint, int and Number uses 4 byte, but how is it with Stings, and Objects? I guess Strings uses 8 bit (UTF8). But how are objects and class definitions handled? Do strings always use chunks with 1 byte blocks or do they divide them up to the next highest block size depending on the length of the string? If a string has 14 chars does it then use a chunk with block size 16?<br />
The reason for my questions is that we have started using object pooling with a few objects which are created by parsing xml data via e4x and we have got 50% less memory leakage. We have to investigate this further but I am wondering if the memory management in the flashplayer could cause our leaks?<br />
As far as we have discovered yet e4x creates a lot of objects and strings internally which needs memory to be allocated and should be freed after parsing, but it seems that this is not cleaned up completely.<br />
Does anyone have more information about this topic?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Christmann</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-5124</link>
		<dc:creator>Sean Christmann</dc:creator>
		<pubDate>Fri, 24 Oct 2008 23:57:50 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-5124</guid>
		<description>Tecsi - Thats great advice actually. We're looking into a very large project coming up that will most likely churn through alot of memory, and I think writing a custom ActiveX control in .NET so we can restart the VM will be our best option rather then relying on a single AIR session.</description>
		<content:encoded><![CDATA[<p>Tecsi - Thats great advice actually. We&#8217;re looking into a very large project coming up that will most likely churn through alot of memory, and I think writing a custom ActiveX control in .NET so we can restart the VM will be our best option rather then relying on a single AIR session.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Christmann</title>
		<link>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-5121</link>
		<dc:creator>Sean Christmann</dc:creator>
		<pubDate>Fri, 24 Oct 2008 23:40:14 +0000</pubDate>
		<guid>http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/#comment-5121</guid>
		<description>Brian - Maybe i should've phrased that differently. SWF based apps on the web are getting bigger and bigger and tighter memory control will be important. But in general, I would say this is a tiny minority in the flash landscape, and one of the reasons they still have exposed the garbage collector to that market.

Jeremy - I hear your pain there. Since you have a custom controlled use case you may benefit jumping to another platform like northcode or jester, but I don't know enough about those platforms to give a good suggestion. I'm guessing you're using alot of high rez images which is eating up your memory. I might suggest getting away from pointing directly to a url to load images and instead, loading them in as a bytearray, and then feeding those bytes to the image class to load, I seemto remember that workflow would unload data better.</description>
		<content:encoded><![CDATA[<p>Brian - Maybe i should&#8217;ve phrased that differently. SWF based apps on the web are getting bigger and bigger and tighter memory control will be important. But in general, I would say this is a tiny minority in the flash landscape, and one of the reasons they still have exposed the garbage collector to that market.</p>
<p>Jeremy - I hear your pain there. Since you have a custom controlled use case you may benefit jumping to another platform like northcode or jester, but I don&#8217;t know enough about those platforms to give a good suggestion. I&#8217;m guessing you&#8217;re using alot of high rez images which is eating up your memory. I might suggest getting away from pointing directly to a url to load images and instead, loading them in as a bytearray, and then feeding those bytes to the image class to load, I seemto remember that workflow would unload data better.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
