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: another way to clean up  (Read 6878 times)
gregbown
Jr. Member
**
Posts: 16


View Profile Email
« on: August 02, 2009, 05:55:16 »

I read in a post elsewhere from Darshan Sawardekar

"In fabrication the module’s facade instance is disposed when unloading the module. A "shutdown" notification is fired before the facade is disposed to allow any custom cleanup to happen inside the module. Typically, a command can register with this notification to execute cleanup within the module."

I tried this by registering a command for this notification in both my shell and module startup commands and neither one would execute.

inside startup command

registerCommand(FabricationNotification.SHUTDOWN, ModulelShutdownCommand);

the ModulelShutdownCommand

   import org.puremvc.as3.multicore.interfaces.INotification;
   import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;

   public class ModulelShutdownCommand extends SimpleFabricationCommand {
      
      override public function execute(note:INotification):void {
         trace("FABRICATION SHUTDOWN");
      }
   }

I am calling dispose() but perhaps I am calling it in the wrong location.  I am not using FlexModuleLoader because my project is Actionscript only.
In the simple routing example it is called after removeChild but I am doing it prior to remove child because   it adversely affected garbage collection like so...

            var moduleName:String = getModuleName(moduleID);
            loaderDict.content.fabricator.dispose();
            loaderDict.content.dispose();
            loaderDict.unloadAndStop(true);
            delete(loaderDict);
            startGCCycle();
            application.removeChild(application.getChildByName(moduleName));

I tried calling dispose in the module on itself as well as in the shell on the module and from the shell produced better memory recovery. I have changed the sequence of removeChild to last because it allows for better garbage collection.  I believe I am doing the same calls as in FlexModuleLoader except for it being still on the display list.

Has anyone else had success with using the SHUTDOWN notification?
Does anyone have another example of how to and when to call dispose?
« Last Edit: August 03, 2009, 03:47:50 by gregbown » Logged
Pages: [1]
Print