Re: [Flashcoders] Weak eventListener Problem

2009-11-08 Thread Ktu
@Steven, I know anonymous functions are horrible, but I was trying to anything to get the GC to pick it up. I'm really just testing, to see how GC might react, and how the weak event listeners work. I know mediocre practice (and higher) you need to remove event listeners. I was just wondering, I'v

Re: [Flashcoders] Weak eventListener Problem

2009-11-08 Thread Keith H
I make destroy methods, avoid using extra references to listeners and am compulsive about cleaning them up, still some continue to execute imperviously. I hate when this happens cause its unpredictable and unexplainable. All I know is the "Real" garbage collectors are sometimes late picking up

Re: [Flashcoders] Weak eventListener Problem

2009-11-08 Thread Steven Sacks
No, it's not true. You're misunderstanding how weak listeners work, how anonymous functions work (you shouldn't use those anyway), and you're also misunderstanding how the garbage collector works. Whenever you addEventListener, immediately write a function that removes the event listener (suc

Re: [Flashcoders] Weak eventListener Problem

2009-11-07 Thread Ktu
So I used the LocalConnection hack to force GC to run, and it cleaned up the object. I was not aware that GC might not run because there isn't enough of a reason to. If I had put this code into a fairly large application, GC would have more of a reason to run and thus probably end up cleaning up th

Re: [Flashcoders] Weak eventListener Problem

2009-11-07 Thread Henrik Andersson
Ktu wrote: That is true, however, this eventListener fires indefinitely. Garbage collection should pick it up after 30 seconds right? I have tried this on the main timeline, and in a document class, but GC never cleans up the object. Why? There is no set time when it will run. It runs when Fla

Re: [Flashcoders] Weak eventListener Problem

2009-11-07 Thread Ktu
That is true, however, this eventListener fires indefinitely. Garbage collection should pick it up after 30 seconds right? I have tried this on the main timeline, and in a document class, but GC never cleans up the object. Why? Ktu On Sat, Nov 7, 2009 at 5:29 AM, Henrik Andersson wrote: > Ktu wr

Re: [Flashcoders] Weak eventListener Problem

2009-11-07 Thread Henrik Andersson
Ktu wrote: When the code below is run, the eventListener still fires. I was under the impression that it would not because the eventListener uses a weak reference, and thus get garbage collected. var sp:Sprite = new Sprite (); sp.addEventListener (Event.ENTER_FRAME, function (e:Event):void {