PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: dancantong on January 27, 2010, 08:48:48



Title: PureMVC module unloading
Post by: dancantong on January 27, 2010, 08:48:48
Hi!
I'm developing a Flex applications based on PureMVC MultiCore and Fabrication.
I'm handling module unloading with following code when needed:

:
ModuleManager.getModule(MODULE_URL).unload();
I would like to free PureMVC module classes acquired memory (including mediators, proxys, etc.) and also MXML classes.

I've noticed that MXML creation complete event is been fired only once, when it is first viewed. I think if module is unloaded properly MXML views should be recreated. Am I right?

Is any extra procedure needed to unload PureMVC related classes when unloading modules?

Thank you in advance.

Daniel.


Title: Re: PureMVC module unloading
Post by: puremvc on January 27, 2010, 10:06:36
Here's a super article on the subject by Simon Bailey. http://www.newtriks.com/?p=132

-=Cliff>


Title: Re: PureMVC module unloading
Post by: stinkyian on January 28, 2010, 06:35:31
Also if you're using Fabrication, you can do:

( ModuleManager.getModule(MODULE_URL) as IDisposable ).dispose();

This will run through all your proxies and mediators (assuming they extend FabricationProxy/FabricationMediator) calling their own dispose methods and nullifying them (can't remember exactly all the steps involved).

It's a good idea to override the dispose method on your proxies and mediators doing any necessary cleanup there. As you're probably aware there are a whole host of things that can stop unload working, such as open netconnections/netstreams, sounds, stage listeners, global refs, etc etc.

Call this before your unload().

It's also worth mentioning if you're publishing for FP10 you can do unloadAndStop() which is a bit more effective than unload(), although still not totally reliable.


Title: Re: PureMVC module unloading
Post by: dancantong on February 02, 2010, 05:37:22
Thank you very much.

So I understand that if views (MXML classes) are not been recreated after unloading and loading a module the problem is the module is not been unloaded at all.


Title: Re: PureMVC module unloading
Post by: puremvc on February 02, 2010, 02:02:23
Correct.
-=Cliff>