tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/8306-old-mediator-is-not-removed-flexRobotlegs: Discussion 2013-12-23T09:26:37Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/301409342013-11-26T12:07:45Z2013-11-26T12:07:45ZOld mediator is not removed (Flex)<div><p>Hello,</p>
<p>I'm sorry for the late response, but your post got stuck into
forum's spam filter, and I haven't notice that until today.</p>
<p>It seems like something is keeping your view(s) alive. The
mediators are destroyed when their views leave the stage and are
garbage collected (null). References to views keep them alive.
There are several possible causes for this. Some things to
check:</p>
<p>[1] Clean up the views when they get removed from stage:</p>
<ul>
<li>
<p>remove event listeners</p>
</li>
<li>
<p>remove child components</p>
</li>
<li>
<p>remove external references</p>
</li>
<li>
<p>remove effects references, tweening listeners, functions
references</p>
</li>
<li>
<p>remove bindings</p>
</li>
<li>
<p>be aware of styles, item renderers that might keep the view
alive</p>
</li>
<li>
<p>setting buttonMode=true, setting focusEnabled=true can also keep
a view from being gc-ed, so set them to false when the view is
removed from stage</p>
</li>
</ul>
<p>[2] Allow Mediators to be destroyed:</p>
<p>If views are mediated, make sure to remove all registered events
and signals listeners. If you're using addViewListener to add event
listeners, they will be automatically removed when mediator's
destroy() runs. But, if you add listeners directly to the view or
its subcomponents, you have to manually remove them inside your
destroy() method. If you're using Signals, destroy() is also the
place were you should -manually- remove the listeners. If you
forget to do so, the <strong>Signals will keep your view and/or
mediator alive</strong>!!!</p>
<p>I'll attach a very simple mobile app. If you're using something
like the Flash Profiler, you can see that the views get garbage
collected and their mediators as well.<br>
If you can't resolve the issue, you might want attaching a
bare-bone project reproducing the problems and I'll take a look at
it. Or, you can modify the attached project to reflect your
settings and let me see it.</p>
<p>hth<br>
Ondina</p></div>Ondina D.F.