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

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Fabrication / proxyNameCache is null inside FabricationProxy on: September 12, 2009, 02:40:11
Error #1009: Cannot access a property or method of a null object reference. thrown on sendNotification inside a proxy

I have two proxies instantiated in my application startup command however one is coming up null unless I use a setTimeout inside the proxy to send notifications.  I tried changing the order of instantiation and even tried an addProxyCommand.

The debugger points to a null value inside FabricationProxy and sure enough proxyNameCache is null inside FabricationProxy line 212 unless I add some kind of delay in witch case it is fine.  The weird thing is both proxies send notifications so why does one throw the error and the other not.  They both have static public const NAME:String="Name of Proxy" and call super(NAME); in their constructor.  Both extend FabricationProxy

The only thing that prevents the error is using a setTimeout to send the notification
2  Announcements and General Discussion / Fabrication / another way to clean up 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?
3  Announcements and General Discussion / Fabrication / Memory management in pure Actionscript module load and unload on: July 27, 2009, 02:20:33
I have a pure Actionscript project that loads and unloads modules.  Since all the examples that unload modules are MXML based I dont have a clear idea of best practice.
So inside a loaded modules mediator I do this after notifying the shell...
               application.parent.removeChild(application);
               application.dispose();
               this.viewComponent = null;
Inside the shell I clear out any reference to the module and call System.gc();

The memory usage goes up with every module and never comes down so I wanted to get some feedback on what I am doing so far.  The module does not have any proxies but if it did what would be best practice?
In a strictly PureMVC Multicore project I would call removeMediator, removeProxy, pipe.disconnect(),
and junction.removePipe().
Again not sure what to do in my case?  I believe dispose() takes care of the pipes, junctions and core but since I am not handling this with FlexModuleLoader the correct methods are a mixture of what I have seen or adapted from other examples and it isn't working.  I'm not sure how to reference the module from the shell once its loader is cleared out.  I considered keeping the loader in an array to reference by index in the shell then the shell could call removeChild(moduleLoader) instead of the module calling application.parent.removeChild(application).
The current loading method follows Hello Flash method with one slight change.
I store the load index and a unique id in the config object of each module. The shell also maintains a hash map with all current modules index and unique id.

         var content:FlashApplication = moduleLoader.content as FlashApplication;
         var moduleID:Object = new Object();
         moduleID = {(index as Number):unique_id}
         content.router = applicationRouter;
         content.defaultRouteAddress = applicationAddress;
         content.config = moduleID;
                        application.addChild(content);

Any clarity would be appreciated.  Step by step would be awesome.
Thank you

Update
I tried the method I eluded to above and placed the loader in an array. This yielded a minor improvement but I am unable to get closer than 1/2 meg of the original memory usage.


Update#2
     I changed the array to a Dictionary(true) to allow for better cleanup.
     I get the child through a reference with its unique ID, removeChild and then call the
     loader.unloadAndStop(true) then I delete the loader from the loaderDictionary.
     For some reason calling application.dispose() works better when called from the shell on the module?
     If I call it from the module mediator the memory usage is the same as if the module is still loaded.
It looks like so...
            var moduleName:String = getModuleName(moduleID);
            application.removeChild(application.getChildByName(moduleName));
            loaderDict.content.config = null;
            loaderDict.content.fabricator.dispose();
            loaderDict.content.dispose();
            loaderDict.unloadAndStop(true);
            delete(loaderDict);
            startGCCycle(); // Does not make a difference
            sendNotification(CommonConstants.GARBAGE_COLLECTION);

I am able to reduce memory by only .4 meg from its loaded state so...
shell startup = 5.5 meg
load module = 6.4 meg
remove module = 6.0 meg

I hope someone can help me improve on this.

Thank you
4  Announcements and General Discussion / Fabrication / respondTo fails but handleNotification works on: July 23, 2009, 04:17:19
Hello,

I have built Module and Shell Actionscript only projects using PureMVC, Pipes and Fabrication.  I load Module.swf into Shell.swf like so...
req = new URLRequest("Module.swf");
moduleLoader = new Loader();
moduleLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);
moduleLoader.load(req);

in completeListener...

var content:FlashApplication = moduleLoader.content as FlashApplication;
content.router = applicationRouter;
content.defaultRouteAddress = applicationAddress;
application.addChild(content);
This seems to be working great, both Module and Shell receive notifications frome each other fine however routing is not working?

in Shell...
routeNotification(CommonConstants.SHELL_TO_MODULE,null,null,"*");//SHELL_TO_MODULE="shellModule"
in Module...
public function respondToShellModule(notification:INotification):void{trace("response recieved");}

I am lost as to how to debug this.  I can inspect the properties of both the module and shell with the Flex debugger but I'm not sure what to look for.  Both router and defaultRouteAddress seem to be getting set. The defaultRoute in the module is set to Shell/Shell0/INPUT.  The applicationAddress is a fabrication.vo.ModuleAddress that is not readable but it is set b in the module so applicationAddress in Shell = (@1b6fda39) and Module defaultRouteAddress = (@1b6fda39). 
The pipes are connected since notifications are sent and received but why are routeNotifications failing?

I have been through the HelloFlash example numerous times and I cant see any differences other than my not using fla files.  There must be something else failing because routeNotification is sending the note fine but only handleNotifications is receiving, respondTo fails?

Any advice is welcome.  Thank you
5  Announcements and General Discussion / General Discussion / should proxy share notifications? on: February 14, 2009, 08:47:32
I have an application that allows customers to preview media, login purchase and and view full library.
Init proxy returns the preview and price only. Login and buy proxy returns the complete library.
There was a request for maintaining the logged in state if a user returns to the page. I now check for a stored session id in a shared object in my init proxy. If it exists I post it to my API and get the complete library back.
My Question
Should I handle the new post structure in init proxy or communicate the session to a application mediator and then handle it in the login proxy.
My other finding.??? I can send the login proxy notification to my application mediator from the init proxy and application mediator handles it as if it came from login proxy and I don't need to write any additional code to handle the response because the structure is already there to handle it ...
Weird.  I guess the proxy's are in the same package so if the sendNotification is public that would explain it
6  Announcements and General Discussion / Getting Started / Delayed command and proxy registration? on: August 12, 2008, 06:34:02
My application needs to give the user a 30 second video followed by a login screen and the option to go directly to the login at any point.
InitProxy gets access to a 30 the second clip url.
loginProxy gets access to the full length video url

InitProxy is registered in StartupCommand.

When and where should I register the loginProxy?
If I use a LoginCommand to register LoginProxy when and where should I register the LoginCommand?

I believe that I need to register them in ApplicationMediator on the event from the view but I have not seen any examples of this.
All the examples assume login is the first action and so registration is always in StartupCommand.  If anyone knows of a deferred registration example please post it.
Thank you
Greg
7  Announcements and General Discussion / Getting Started / Best practice for adding the aplication to the stage in AS3 only projects on: July 30, 2008, 04:16:10
What is the best practice for adding the main application to the stage?  I have been working on a pure AS3 PureMVC video player and I see two very diferent methods of adding the player to the stage.  The most common method http://etc.joshspoon.com/2008/02/13/how-to-create-a-puremvc-app-with-actionscript-3/  http://www.nutrixinteractive.com/blog/?p=85 in pure as3 projects I have seen is to add the component to the stage within the main class that calls ApplicationFacade.getInstance().startup( this.stage );.  The other method is http://hubflanger.com/building-a-flash-site-using-puremvc/ as in HelloFlash http://puremvc.org/component/option,com_wrapper/Itemid,144/ where the object to be added to the stage is defined within a component class and added to the stage by the StageMediator.
Pages: [1]