<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc = "http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
	<channel rdf:about="http://livedocs.adobe.com/">
	<title>LiveDocs Comments - flash - 9.0 - ActionScriptLangRefV3 - flash/events/EventDispatcher.html</title>	
		<link>http://livedocs.adobe.com/</link>
		<description>Macromedia LiveDocs - online documentation with user feedback.</description>
		<copyright>Copyright 2009, Macromedia, Inc.</copyright>
		<dc:date>2009-11-26T11:15:11</dc:date>
		<dc:language>en-us</dc:language>
		<items>
			<rdf:Seq>
				<rdf:li rdf:resource="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/EventDispatcher.html#82504" />
			</rdf:Seq>
		</items>
	</channel>
	
	<item rdf:about="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/EventDispatcher.html#82504">
		<title>flash/9.0/ActionScriptLangRefV3/flash/events/EventDispatcher.html</title>
		<link>http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/EventDispatcher.html#82504</link>
		<description>Out of concern about the garbage collection of objects with event listeners, I ran a few experiments. I created a parent class with an enter frame event listener that instantiated a child each frame and displayed the memory usage of Flash, like so:&lt;br /&gt;&lt;br /&gt;Parent&lt;br /&gt;{&lt;br /&gt;    function enterFrame(event:Event):void&lt;br /&gt;    {&lt;br /&gt;        var c:Child = new Child();&lt;br /&gt;        trace(System.totalMemory);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The child is not added to the display list and after enterFrame(), the parent has no references to it. By watching the memory usage, I determined that if the child...&lt;br /&gt;&lt;br /&gt;1. Has a keyboard or mouse event listener on itself citing a function either within the child class or outside, it is garbage collected.&lt;br /&gt;&lt;br /&gt;2. Has a reference to the parent [as in c = new Child(this)], it is garbage collected.&lt;br /&gt;&lt;br /&gt;3. Has a limited cycle timer with an event listener pointing to a function either within or outside the class, it is garbage collected.&lt;br /&gt;&lt;br /&gt;4. Has an enter frame event listener, it is _not_ garbage collected.&lt;br /&gt;&lt;br /&gt;5. Has an infinite cycle timer, it is _not_ garbage collected. Even if the child no longer maintains a reference to the timer.&lt;br /&gt;&lt;br /&gt;6. Has an event listener placed on an outside object (such as the parent) pointing to a function within the child class, it is _not_ garbage collected.&lt;br /&gt;&lt;br /&gt;The garbage collection scheme is thus quite intelligent. If you were to create a button object, for example, with only mouse and keyboard event listeners, there is no need to be concerned with memory issues caused by not removing event listeners.&lt;br /&gt;&lt;br /&gt;-Josh</description>
		<dc:creator>Josh Devan</dc:creator>
		<dc:type>0 0</dc:type>
		<dc:date>2008-03-31T13:38:19</dc:date>
	</item>
	</rdf:RDF>

