6 Replies Latest reply on May 31, 2010 7:18 AM by John Hall

    Unloading sub module

    JessyEzzy

      I have an application that loads a module and that module loads another sub module, when I unload the module from the main application does the sub module get unloaded too?

      If the sub module doesn't get unloaded how can I unload it when its loader module gets unloaded?

       

      Thanks

        • 1. Re: Unloading sub module
          Darrell Loverin Level 4

          The sub-module will be unloaded as long as there are no references to keep it in memory. Technically, a module's swf is unloaded after the ready event. Only references from objects on the display list and statics keep the module in memory.

           

           

          -Darrell

          • 2. Re: Unloading sub module
            JessyEzzy Level 1

            >>The sub-module will be unloaded as long as there are no references to keep it in memory

            Does this means that I cannot unload it as long as it has references, what if I want to unload the sub module programmatically when the parent module gets unloaded.

             

            In my application I have a ModuleLoader for which the url is changed on the runtime, each time the url changes I unload the previously loaded module and I need to unload sub modules too but I cant figure out how.

             

            Thanks

            • 3. Re: Unloading sub module
              Flex harUI Adobe Employee

              If the only references to the sub module are from the module, they will all

              go away when the module goes away.  Use the profiler to see if there are

              other references.

              1 person found this helpful
              • 4. Re: Unloading sub module
                Darrell Loverin Level 4

                It looks like if you don't explicitly unload a sub-module it will be pinned in memory. To avoid that it is necessary to recursively unload all sub-modules before unloading a module. This can be done by recursively iterating over a ModduleLoader's children and calling ModuleLoader.unloadModule() on all children of type ModuleLoader.

                 

                When a module is unloaded I think its child modules should be available for garbage collection, which they currently are not. I'll write up a bug tomorrow.

                 


                -Darrell

                • 5. Re: Unloading sub module
                  Darrell Loverin Level 4

                  >>It looks like if you don't explicitly unload a sub-module it will be pinned in memory. To avoid that it is necessary to recursively unload all sub-modules before unloading a module. This can be done by recursively iterating over a ModduleLoader's children and calling ModuleLoader.unloadModule() on all children of type ModuleLoader.

                   

                  I wanted to clarify my previous post about the sub-module being pinned in memory. When I said "module" I was talking about part of the module that represents the loaded SWF, not the Module component and its children. The Module component and its children, in a sub-module, can be garbage collected when its parent module is removed from the display list. The SWF part of a module is not available for garbage collection unless it is explictly garbage collected.

                  1 person found this helpful
                  • 6. Re: Unloading sub module
                    John Hall Level 4

                    What's the bug number for this. Or, more importantly, is it resolved in the final release of FB4? I'm finally diving into modules and finding myself with a mess of things not garbage collected. Before I refactor, I wanted to make sure this is not longer the issue I may be running into. Thanks much.