I think Amy's point is that, w/o a reference to the anonfun, you can't call 
removeEventListener on it.  If I do:

someObj.addEventListener("foo", function (e:Event) { ... } );

someObj will release the anonfun when it gets garbage collected.  However, 
until that time, all objects in the scope chain won't be collectable.  I don't 
know if that's the case in Java.

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Mark Carter
Sent: Friday, December 12, 2008 6:28 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Best practice for calling asynchronous functions?


So are you saying that, in general, anonymous functions should not be used as
listeners?

If its anything like in Java, (once the calling method returned) the
anonymous function would only be referenced by the event dispatcher and so
(assuming weak references are not used) would only be garbage collected when
the event dispatcher is garbage collected. At least, that's how I understand
it.

I posted a question about this a few weeks ago, but didn't get a reply.

Amy-28 wrote:
>
> My understanding is that anonymous functions _cannot_ get garbage
> collected unless you use weak references when you add them. Which
> means there's a really good chance they'll get garbage collected
> before they get called.
>

--
View this message in context: 
http://www.nabble.com/Best-practice-for-calling-asynchronous-functions--tp20930596p20976648.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to