<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Just Flex &#187; Garbage Collector</title>
	<atom:link href="http://olehfilipchuk.com/category/flash-platform/garbage-collector/feed/" rel="self" type="application/rss+xml" />
	<link>http://olehfilipchuk.com</link>
	<description>another technology blog</description>
	<lastBuildDate>Sun, 25 Jul 2010 20:52:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>unload you module</title>
		<link>http://olehfilipchuk.com/2009/07/24/unload-you-module/</link>
		<comments>http://olehfilipchuk.com/2009/07/24/unload-you-module/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 09:23:34 +0000</pubDate>
		<dc:creator>justversus</dc:creator>
				<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Garbage Collector]]></category>

		<guid isPermaLink="false">http://olegfilipchuk.com/?p=46</guid>
		<description><![CDATA[If you are using modules in your application sooner or later you will get some nice memory leaks, 100% guarantee. It's "simples", not much effort required, just add TextInput to your module. The FocusManager keeps references to all focusable components in private focusableCandidates property (SDK 3.4.0). When you are trying to unload your module, the [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using modules in your application sooner or later you will get some nice memory leaks, 100% guarantee. It's <a href="http://comparethemeerkat.com/my-movies" target="_blank">"simples"</a>, not much effort required, just add TextInput to your module. The FocusManager keeps references to all focusable components in private focusableCandidates property (SDK 3.4.0). When you are trying to unload your module, the FocusManager doesn't revalidate the list of focusable candidates leaving references to one or more components owned by the module. Unless you explicitly set focus to any other TextInput outside the module before actually invoking unload procedure, the module will never get garbage collected introducing some nice source of memory leaks.</p>
<p><a href="https://bugs.adobe.com/jira/browse/SDK-22381"> The issue has already been reported to Adobe Jira</a> by my colleague from the previous project. The bug exists in Flex SDK 3.4.0 and 4.0.0 as well.</p>
<p>I assume you vote to prioritize this issue as it is very serious bug stopping any developer from utilizing modular infrastructure in flex applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://olehfilipchuk.com/2009/07/24/unload-you-module/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>clean up your garbage</title>
		<link>http://olehfilipchuk.com/2009/03/15/clean-up-your-garbage/</link>
		<comments>http://olehfilipchuk.com/2009/03/15/clean-up-your-garbage/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 21:35:35 +0000</pubDate>
		<dc:creator>justversus</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Garbage Collector]]></category>
		<category><![CDATA[IDisposable]]></category>

		<guid isPermaLink="false">http://olegfilipchuk.com/?p=19</guid>
		<description><![CDATA[We don't live in an ideal world where flash player's garbage collector understands our brilliant ideas and our incredibly genius way of coding flex applications. As you may already know, using weak event listeners with modules and pop-ups often results in memory leaks. It's really painful to fully remove modules from memory if in-line styles, [...]]]></description>
			<content:encoded><![CDATA[<p>We don't live in an ideal world where flash player's garbage collector understands our brilliant ideas and our incredibly genius way of coding flex applications.<br />
As you may already know, using weak event listeners with modules and pop-ups often results in memory leaks. It's really painful to fully remove modules from memory if in-line styles, effects or focus enabled controls are present in the module.<br />
Unfortunately, it's all up to the individual developer. Here in Lab49 we use IDisposable interface that every disposable domain object, presentation model or view should implement.</p>
<pre class="actionscript">&nbsp;
package com.<span style="color: #006600;">lab49</span>.<span style="color: #006600;">core</span>
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IDisposable
   <span style="color: #66cc66;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">function</span> dispose<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>;
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>The main concept is very simple - every parent cleans up itself, its presentation model and calls 'dispose' method on its children if it's applicable.</p>
<pre class="actionscript">&nbsp;
&lt;myComp
   <span style="color: #0066CC;">implements</span>=<span style="color: #ff0000;">&quot;com.lab49.core.IDisposable&quot;</span>
   layout=<span style="color: #ff0000;">&quot;absolute&quot;</span>
   <span style="color: #0066CC;">close</span>=<span style="color: #ff0000;">&quot;dispose()&quot;</span>&gt;;
   &lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
	      <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">lab49</span>.<span style="color: #006600;">core</span>.<span style="color: #006600;">IDisposable</span>;
	      <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">lab49</span>.<span style="color: #006600;">example</span>.<span style="color: #006600;">model</span>.<span style="color: #006600;">BasePresentationModel</span>;
&nbsp;
	      <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
	      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> model : BasePresentationModel;
&nbsp;
	      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> dispose<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
	      <span style="color: #66cc66;">&#123;</span>
	         <span style="color: #808080; font-style: italic;">//remove all event listeners here, stop all effects, clean up model</span>
	         <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> model <span style="color: #66cc66;">&#41;</span>
	         <span style="color: #66cc66;">&#123;</span>
	            model.<span style="color: #006600;">dispose</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	         <span style="color: #66cc66;">&#125;</span>
	         <span style="color: #808080; font-style: italic;">//Clean up children</span>
	         <span style="color: #000000; font-weight: bold;">var</span> children : <span style="color: #0066CC;">Array</span> = getChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	         <span style="color: #b1b100;">for</span> each<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> child : DisplayObject <span style="color: #b1b100;">in</span> children <span style="color: #66cc66;">&#41;</span>
	         <span style="color: #66cc66;">&#123;</span>
	            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> child is IDisposable <span style="color: #66cc66;">&#41;</span>
	               IDisposable<span style="color: #66cc66;">&#40;</span> child <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">dispose</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	         <span style="color: #66cc66;">&#125;</span>
	      <span style="color: #66cc66;">&#125;</span>
   <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;
&lt;/script&gt;
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://olehfilipchuk.com/2009/03/15/clean-up-your-garbage/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
