"bill.cabral" <webforumsuser@macromedia.com> wrote in message
news:gdqvng$cav$1@forums.macromedia.com...
> Hey everyone,
>
> I hope somewhere can help me with this, because I have been running in
> circles
> on this. I am developing on a fairly large application and have recently
> noticed that instances of my class that have event listeners of data
> binding
> tied to them cannot be garbage collected. It has led to some
> fantastically
> bizarre artifacts and some gross memory leaks. Multiple copies of screens
> modifying and accessing the same array collections and such...fun. The
> way I
> see it, there are three real solutions here...
>
> 1.) dictate that all programmers declare weak references when creating
> event
> listeners
> 2.) create some sort of onDestroy method that kills bindings and removes
> eventlisteners when a child is removed from it's parent
> 3.) override the addEventListener method to ensure that weak references
> are
> made, when people inevitable forget #1!
>
> My questions are thrice: are those my only options?! Or have any of you
> more
> experienced folks conquered this situation in a more elegant, reliable
> way? If
> these are my only options, which is the best, in your opinions?
>
> Thank you very much for any info you can give; I'm relatively new to Flex
> and
> while I understand the GC's terms and conditions, I'm hoping there is some
> way
> to avoid a massive rewrite/refactoring to make it work with me. Thanks
> again!
There aren't any easy answers, but this might point you in the right
direction:
http://link.brightcove.com/services/...tid=1741212660
Keep in mind that any event listeners added within the scope of a component
will be destroyed when the component is destroyed.
so this.addEventListener=OK
that.addEventListener=may not be
HTH;
Amy