0 Replies Latest reply: Aug 6, 2009 8:06 AM by kilyas2007 RSS

    loading and unloading Modules

    kilyas2007 Community Member

      I am using ModuleLoader to load  swf files in my application as follows:-

       

       

       

       

       

       

       

       

      private

       

       

      function loadModule(modulName:String):void

      {

          moduleInfo = ModuleManager.getModule(modulName);

          moduleInfo.addEventListener(ModuleEvent.READY, renderModule);

          moduleInfo.addEventListener(ModuleEvent.ERROR, handleError);

          moduleInfo.load();

      }

       

       

       

      private function renderModule(event:ModuleEvent):void

      {

          moduleToBeLoaded = moduleInfo.factory.create()

      as Module;

          moduleToBeLoaded.width = containrOfTheModule.width;

          moduleToBeLoaded.height = containrOfTheModule.height;

          containrOfTheModule.addChild(moduleToBeLoaded);

      }

       

       

      The call to loadModule is made as follows:-

      loadModule(

      "SummaryApplication.swf");

       

      So far so good.  The problem is that when I unload a module, I don't think it is being unloaded properly since I cannot see the reduction in the memory usage.  On the contrary what I am seeing is a continuous increase in the memory as these modules are loaded and unloaded.  So if I continue switching between two swf files, the memory footprint continues to increase.  Unload is as follows:-

       

       

       

       

       

       

       

       

       

      private

       

       

      {

       

       

           if(null!=containrOfTheModule){

       

       

      function unloadSWF():void

                containrOfTheModule.removeAllChildren();

       

       

       

      null;

       

       

                 trace("unloading");

           }

       

       

           if(null!=moduleInfo){

                moduleInfo.unload();

           }

      }

       

       

       

       

      Please advise how can I fix this?