Hi everyone, My name is Jorge Maiquez, and this is my first post here. My question relates to the AVM2 garbage collection mechanism. I have asked it elsewhere but have not gotten a response. Here it goes:
>From the AS3 docs: "Objects with registered event listeners are not automatically removed from memory because the garbage collector does not remove objects that still have references." How does this work with local (function) variables to which we attach event listeners? For example, if we have a class with these methods: private function setEvents():void { var _ldr : URLLoader = new URLLoader(); _ldr.addEventListener(Event.COMPLETE, onComplete); } private function onComplete(e:Event):void { // _ldr is referenced by e.target } Is it a bad idea to make _ldr a local variable? Afaik, local variables are marked for garbage collection after the parent method has executed, right? But _ldr is an "object with a registered event listener". Does this mean that _ldr will never be garbage collected? So if I call the setEvents method a 1000 times, will I have a 1000 _ldr's kicking around in memory? Thanks in advance! -Jorge