Running a GC cycle is rather intensive and can definitely have an impact on
performance. It's a trade-off. You hold some memory for a little longer than
you actually need, but you save on performance (and many times, memory is
just sitting there with no one using it anyway... also, allocating and
deallocatin has a cost too).

Think about this. How do you know it's better to run a GC than holding back,
say 50 Mb (in a computer that might have, say, 1 Gb to spare)? From
actionscript, there's no way you can know when it's best. The GC has
a better chance to make an educated guess, because it has access to some
data that is not available to you.

Cheers
Juan Pablo Califano


2010/1/6 Karl DeSaulniers <[email protected]>

> So there is no way to fire the garbage collector from actionscript?
> This seems odd to me if that is the case. If the flash applications
> performance is dependent partly on how well the garbage is taken out,
> wouldn't there be a class made for that so we can control it? Or is it too
> risky to be messing with that part?
> Just curious.
>
> Karl
>
>
>
> On Jan 6, 2010, at 5:02 PM, Henrik Andersson wrote:
>
> Event listeners will be destroyed along with the object the listeners
>> belong to. But they will keep on firing until the garbage collector feels
>> like running.
>>
>> Do note that a listener does hold a reference to the listener function
>> from the event source. This means that if the object has a listener on some
>> object that is not up for garbage collection (like the stage), it is not
>> going to be garbage collected either. That's why there is a fifth argument
>> to addEventListener.
>>
>> So yeah, removing the listeners can be needed in some cases, and not
>> needed in other cases. Either way, it is good practice to do remove them.
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to