Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Can't remove Mediator object from memory!  (Read 6785 times)
SatanClaus
Newbie
*
Posts: 3


View Profile Email
« on: March 13, 2008, 03:45:35 »

Good day!
I have problem with mediator objects removing.
My program is cuted into modules. In beginning, when i press button for window opening, some my Commans is running from Facade. In this Command will create Mediator and Proxy:
:
......
override public function execute(note:INotification):void
{
sysParamProxy = facade.retrieveProxy(SysParamProxy.NAME) as SysParamProxy;

if (sysParamProxy == null){
sysParamProxy = new SysParamProxy();
facade.registerProxy(sysParamProxy);
}
module = note.getBody() as SysParamModule;

sysParamMediator = facade.retrieveMediator(SysParamMediator.NAME) as SysParamMediator;

if (sysParamMediator == null){
sysParamMediator = new SysParamMediator(module.sysParamCreatePanel);
facade.registerMediator(sysParamMediator);
}

sysParamProxy.getSysParams();
}
.....
Then when i window is open, i press some button that dispatch some event SAVE_SYS_PARAM
Mediator retrieve this event and run some function, that run function in proxy.
:
private function onSave(event:Event):void
{
sysParamProxy.saveSysParams(event.target.sys_param as ArrayCollection);
}
When proxy continue with function, it send notification ApplicationFacade.SYS_PARAM_SAVED and Mediator than execte some code
:
public override function handleNotification(note:INotification):void
{
var data:Array;
switch (note.getName()){
case ApplicationFacade.SYS_PARAM_RECEIVED:
{
data = (note.getBody() as ArrayCollection).source;
sysParamPanel.sys_param = new ArrayCollection(data);
break;
}
case ApplicationFacade.SYS_PARAM_SAVED: // This code will be executed
{
trace("alert");
Alert.show("Settings saved");
}
default: break;
}
}
And now my question: When i first open window and press button i become one message "Alert", than i close window and open it one more and press button. This time i become two messages Alert, when i close window one more, i become 3 messages "Alert"...
It seems like my Mediators are not deleted from my Facade. I have traced and know, that with proxies is all right. How can i right delete my Mediators?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 13, 2008, 05:13:51 »

Nowhere here do you show the code that actually removes the Mediator.

When you remove a Mediator from the View, you stll need to remove all references before it will be garbage collected. This means removing any event listeners it has placed on its view component.

In 2.0.1 this can be done in the mediator's onRemove method.

However that doesn't sound like what's happening because you check that the mediator is not there before instantiating. This could fail if your SysParamsMediator.NAME is not defined.

But most likely you have an old version of PureMVC. This sounds like a problem that was cleared up around V 1.6 or 1.7.

Unfortunately the swc itself wasn't being numbered back then so if it is just PureMVC.swc you need to upgrade.

Note that 2.0.1 requires a simple migration. If you want, you can check out tags/1.7.1 from the repository and drop in replace what you have to see if this is it.

Also for modular apps, you may want to look at the MultiCore version which is specifically for this purpose.

-=Cliff>
Logged
SatanClaus
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: March 13, 2008, 10:30:36 »

Thank you, man. Problem was in PureMVC version. I'm now very happy! Respect for you )))  ;D
Logged
Pages: [1]
Print