Support Staff2 Posted by Ondina D.F. on 25 Apr, 2012 03:48 PM
Have you tried to force the gc: “Run Garbage Collector”
in the profiler?
After removing it from the display list an object doesn’t get
gc-ed right away, it just becomes a candidate for gc.
Support Staff6 Posted by Ondina D.F. on 25 Apr, 2012 04:10 PM
Have you tried to add/remove the components directly within the
contextView (the display object) ?
Can you try to add/remove a simple view without sub-components the
same way you did with your myViewA and see if it gets gc-ed?
And for your last post, as i tell you i'm not keeping reference
of the new instance of my view i just create it in the addElement
method : addElement(new MyView())
and to remove it i just kept a reference on it somewhere else, and
this reference is "cleaned" when i change the view 'cause this
properties take the new view instance.
Yeah, it’s better to post an example, so I can see how
you’re handling this reference to the view.
First thing that I found to be a problem was the Button in
ViewOne – btnView. I’m not sure if it has to do with
focus, buttonMode or whatever, but it seems to be a bug (??)
I changed the event listener in ViewOneMediator from
eventMap.mapListener(view.myLabel, MouseEvent.CLICK, onMouseClick,
eventMap.mapListener(view, ViewsEvent.ViewOneOnClick ,
onViewClick);//a custom event – the name is bad, I know
but that didn’t solve the problem.
Then I commented out the button and I added an event listener to
the Label’s click.
Second thing was the reference to the view in your model, which
kept the view alive. So, I did this in the onRemove() of
and after that ViewOne got gc-ed!
I tried to set the view to null in onRemove() as well, but
without the 2 other solutions mentioned above it didn’t
Then I added the same logic to ViewTwo and ViewTwoMediator.
In this scenario viewModel.currentView was replacing the views
accordingly, and indeed, it didn’t keep a reference to the
Thus, the viewModel.currentView=null; was superfluous.
So the conclusion is, that the Button is the culprit. Bad, bad
Flex Buttons;) I don’t have time to investigate why it is
behaving like this and whether it is indeed a bug or not. If you
find out what’s wrong, please let us know.
Oh, ok. I’ll have to clean it up first, because it’s
a mess right now, after the many things I tried.
On a side note, why aren’t you using a ViewNavigator or
something like this, since it’s a mobile app?