Alex,
I think your explanation should find it's way into the product's
documentation. I often wondered if inline event handlers are good or bad
in terms of reference management when it comes to dynamically removing /
adding MXML based components.
Dirk.
________________________________
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui
Sent: Sunday, April 15, 2007 11:11 PM
To: [email protected]
Subject: RE: [flexcoders] Inline MXML event handlers - weak
reference?
They are not weak, because they don't have to be. When you say:
<mx:Button id="button" click="doSomething" />
The MXML compiler wraps doSomething in a function like this in
the application:
public function __Button__click(event:Event):void
{
doSomething();
}
and the Flex framework code calls
button.addEventListener("click", __Button__click);
This puts a reference to the application's __Button__click
method in the button's event handler table. There are no additional
pointers to the button from the application so it does not prevent
collection should you remove the button.
I have a presentation on garbage collection and memory on my
blog
http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html
You can use -keep-generated to view the generated code from
MXMLC.
-Alex
________________________________
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of geoffreymina
Sent: Saturday, April 14, 2007 8:14 AM
To: [email protected]
Subject: [flexcoders] Inline MXML event handlers - weak
reference?
Does anyone know if the event handlers you inject into MXML
components
are weak references? There is no way to remove the event
handler, so I
don't see how they couldn't be... but I am struggling with lots
of
memory leak issues right now and this could be the source.
Thanks,
Geoff