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 <he...@henke37.cjb.net>wrote:

> 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 {
>>     trace(getTimer());
>> }, false, 0, true);
>> sp = null;
>>
>> Am I just wrong?
>>
>>  Yes and No. Yes, in that you assume that just removing all references
> will stop the listener right there and then. No, in that it will be eligible
> for garbage collection.
>
> But there is no guarantee when the garbage collection is performed, and
> until it has been performed, the listener will keep on working.
>
> If you need things to stop doing things _now_, turn them off yourself.
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to