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: PureMVC module unloading  (Read 5088 times)
dancantong
Jr. Member
**
Posts: 12


View Profile Email
« 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.
« Last Edit: January 27, 2010, 09:06:07 by dancantong » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
stinkyian
Newbie
*
Posts: 4


View Profile Email
« Reply #2 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.
Logged
dancantong
Jr. Member
**
Posts: 12


View Profile Email
« Reply #3 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.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: February 02, 2010, 02:02:23 »

Correct.
-=Cliff>
Logged
Pages: [1]
Print