Yes.  That's precisely what I'm doing.  Only, looking at the code now I realize 
most of the time I'm using nested functions (with names) rather than anonymous 
functions.  I'm not sure what the implications are of using one over another 
are but, regardless, I gather you're suggesting this is a potential problem?  

A typical example of what I'm doing would be something like:

private function showDialog(x,y,z):void
{
  var dialog:SomeDialog = new SomeDialog();
  dialog.addEventListener("ok", function doSomething(e:DialogEvent):void 
                                {
                                  someMethod(x,y,z);
                                }
  dialog.show();
}

I'm using the nested function because I need some way to get the x,y,z values 
into someMethod.  Does this code look problematic?

Thanks much for your help!

Lew


--- In [email protected], Alex Harui <aha...@...> wrote:
>
> Could you be registering anonymous functions as event listeners and other 
> callbacks?
> 
> 
> On 8/30/10 12:52 PM, "lew.miller" <lew.mil...@...> wrote:
> 
> 
> 
> 
> 
> 
> Thanks Alex.  I don't have any simple test case indicating that they leak, 
> I'm just struggling to understand what is causing certain leaks in a large 
> application where the profiler points me to activation objects.
> 
> So when tracking memory leaks with the FB4 profiler you're saying one 
> can/should simply ignore any object reference paths that start with 
> activation objects?  (If so, it would be nice if they weren't reported--but 
> that's a separate issue.)  Can you tell me what it means when the profiler 
> lists activation objects?  Does that imply some corresponding function is 
> executing at the time the memory snapshot was taken?  If I understood why I'm 
> getting all these references from activation objects I'd feel a bit more 
> comfortable about ignoring them. :-)
> 
> My application makes use of anonymous functions in places and I read an old 
> Adobe Developer Connection article that says:
> 
> "Defining functions on the fly causes an arcane memory leak in Flash Player 
> because the activation object sent to the function can never be recovered by 
> the garbage collector. So the bottom line is to avoid dynamic classes and 
> explicitly define all the properties and functions used in your classes."
> 
> It doesn't elaborate and was written in 2006 so it may be irrelevant but 
> makes me wonder.
> 
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , 
> Alex Harui <aharui@> wrote:
> >
> > AFAIK, they do not cause leaks.  If you show some data or a simple test 
> > case that indicates that they are, I will try to take a look.
> >
> >
> > On 8/30/10 8:36 AM, "lew.miller" <lew.miller@> wrote:
> >
> >
> >
> >
> >
> >
> > I've been wrestling with memory leaks and the FB4 profiler and lately have 
> > been trying to understand activation-objects and their relationship to GC 
> > because the vast majority (often all) of the references the profiler tells 
> > me an object has keeping it in memory come from activation objects.
> >
> > While researching this I came across a note from Alex Harui saying "I've 
> > never seen an activation object cause a leak" but other things I've read 
> > seem to suggest they can.  (Certainly the profiler would lead me to believe 
> > it.)  Can anybody enlighten me?  Or just point me to the place to read 
> > documentation on the subject that is up-to-date?  Half of what I've read 
> > about activation objects appears to be from earlier versions of 
> > ActionScript so I'm not sure what to believe.
> >
> > If an activation object can cause a memory leak, I'd like to understand 
> > how.  I may not have a firm grasp of the lifecycle of an activation object 
> > but I thought it would no longer be accessible from the GC root after the 
> > function it's created for finishes executing.
> >
> > Any help or pointers would be greatly appreciated.
> >
> > Lew
> >
> >
> >
> >
> >
> >
> > --
> > Alex Harui
> > Flex SDK Team
> > Adobe System, Inc.
> > http://blogs.adobe.com/aharui
> >
> 
> 
> 
> 
> 
> 
> --
> Alex Harui
> Flex SDK Team
> Adobe System, Inc.
> http://blogs.adobe.com/aharui
>


Reply via email to