So is it correct then that if you bind to something outside, say like to a
singleton Model, then that binding creates a link which the author has no
control over and can not destroy. So lets I have an example like:
<Canvas title="{Model.instance.applicationTitle}" />
Then that simple binding will cause every instance of this component to be
created and never GC'd? We as Flex developers have no official way to tell
this MXML based binding to unwatch and thus no way to clear the strong
reference from the singleton Model to the component. Isn't this a huge
memory leak? I don't understand how to reconcile this with your
recommendation of being wary of reading outside to other parts of the app.
Are you saying we should not use MXML based bindings to reach outside our
component at all?
Thanks,
Sam
-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
_____
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Matt Chotin
Sent: Wednesday, January 23, 2008 12:41 PM
To: [email protected]
Subject: RE: [flexcoders] destructing objects / memory management best
practices
No, you're right that binding does not use weak listeners (we tried at the
end of Flex 2 development and found some really bad bugs if we did that).
So I shouldn't be making a global statement about don't check bindings. But
I guess my point is not that not all bindings are bad, especially when done
within a single MXML document that doesn't try to reach outside. Best
practice is to be wary of how easily you reach out into other parts of the
app. The more you can centralize that kind of thing, the easier it is to
have code that releases listeners, references, etc.
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Samuel R. Neff
Sent: Wednesday, January 23, 2008 9:25 AM
To: [email protected]
Subject: RE: [flexcoders] destructing objects / memory management best
practices
Matt,
My understanding from reading the binding code is that bindings do not use a
weak reference when they add an event listener, so bindings must be cleared
(unwatched) in order for an object to be available for GC? Are bindings
created through MXML automatically unwatched at any point? Or am I wrong
about bindings using a strong reference?
Thanks,
Sam
-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]