9 Replies Latest reply on Oct 23, 2009 12:50 AM by Frank F._

    Alert or Popup in Modules

    Frank F._

      Hi,

       

      i'm developing an applicatin who uses Modules. The modules load and unload well and after unload a module, i can see in the profiler, the garbage collection remove the instance. so far so good.

       

      now, i'm using a popup or alert in my modul (for data modification).

       

      I load and unload my module again, without starting the alert or popup and all works fine. but after clicking a button, which triggers an alert, and unload my module again, the module won't remove by garbage collection. my instances in profiler is 1. Doing the same procedure, i generate in profiler two instances but after unload the module, the instance fell down to 1.

       

      So i assume, that flex hold a reference to the alert-window i the first case. the second use the reference from the first. accordingly, the second will be garbage collected.

       

      i'm trying to register the PopupManager in my ApplicationDomain with the follwowing two lines: import mx.managers.PopUpManager;  and privat var popuop:PopupManager. But nothing changes.

       

      What is the right way to use Alerts (or Popups) in modules without references.

       

      Here is my code:

      To open my popup with an mxml-component:

      PopUpManager.addPopUp(inputMask,Application.application as DisplayObject, true);

       

      and my handler for the close-event of my mxml-component:

      PopUpManager.removePopUp( CDBInputMask(event.currentTarget));

      inputMask = null;

       

      Thanks in advanced.


      Frank

        • 1. Re: Alert or Popup in Modules
          Frank F._ Level 1

          Allright,

           

          my Problem is completely different.

           

          I try to implement an empty popup and all works fine.

           

          while testing these i recognize the follwoing behavior:

          a datagrid is ,at this time the, the one and only component in my module.

          if i click in the grid (selecting a row) or typing something with the keyboard in NIL while the grid has the focus, my module is unloading but never garbarge collected. if i set the grid to enabled = false, all works fine!

           

          i try to set the id of my grid to null, befor unload the module, but nothing changes.

           

          do you have a hint for me, how can i delete all referneces, so my unloaded modules will be garbage collected?

           

          you can also see the behavior in the zip-File. All works fine, until you click in the dg. After a click, the simpleModule won't be garbargeCollected (the instance don't go back to 0).

           

          thanks in advanced

          Frank

          • 2. Re: Alert or Popup in Modules
            Flex harUI Adobe Employee

            Use the profiler to see what is holding a reference.  Also read the post on my blog about unloading modules.

             

            Alex Harui

            Flex SDK Developer

            Adobe Systems Inc.

            Blog: http://blogs.adobe.com/aharui

            • 3. Re: Alert or Popup in Modules
              Frank F._ Level 1

              hi alex,

               

              wow someone answered. Thank you!

               

              Believe it or not, after my first post, i found your blog and did my tests.

              so i create the minimal example from chafic kazoun (oreilly) and add a datagrid to the simple module.

               

              do you try the minimal example with a profiler and can you see my problem?

               

              i try to find out, what you mean with "use the profiler and see what is holding a reference.

              can you give me a deeper explanation?

               

              i'm not sure, if your blog fit exactly, because:

              my module was defently unload

               

              trace (moduleInfo.loaded);

              moduleInfo.unload();
              moduleInfo.release();

              trace (moduleInfo.loaded);

               

              brings true and false on the screen.

               

              But a instance hangs in the profiler. when i'm load the module again click on the grind and unload it, the reference goes from 2 to 1. Now i'm load the module again, klick on the grid and typing some letters with the keyboard, unload the module, the instance hangs now on 2. doing the same, the instance fell from 3 to 2. i assume, that keyboard and mouse inputs create some references.

               

              can you please try my example and find out, whats goes here wrong?

               

              i'm confusing about the last lines in your blog. a debug-version can cause some pins modules and a shold try it with an release version without an FP debugger. But without these i'm unable to check, if an instance hang in memory.

              • 4. Re: Alert or Popup in Modules
                Flex harUI Adobe Employee

                I won't have time to try your example any time soon.  Which version of Flex are you using?  Make sure you're on the latest.

                 

                moduleInfo's loaded property simply reflects whether it has released its reference.  Any other references will still pin it.  The profiler will show that.

                 

                There is a post on my blog about unloading modules and it says that the last focused thing can get pinned in memory, and new classes not in the main app will get pinned by the StyleManager.  If you don't have DataGrid in the main app and put it in the module, the first load of the module will get pinned.

                 

                To test with the release player, write a timer loop that loads and unloads the modules every few seconds and let it run overnight.  It'll crash if memory continues to leak.

                 

                Alex Harui

                Flex SDK Developer

                Adobe Systems Inc.

                Blog: http://blogs.adobe.com/aharui

                • 5. Re: Alert or Popup in Modules
                  Frank F._ Level 1

                  Alex,

                   

                  thank you again.

                   

                  I'm trying to get the information as you said:

                  "moduleInfo's loaded property simply reflects whether it has released its reference.  Any other references will still pin it.  The profiler will show that."

                  can you give me a hint, how can i get this information.

                   

                  After pinning my module on memory caused by click on dg, the simpleModule will be shown in the loitering objects and i can see (48) behind it. but it's hard for me to find the references created by frameword or creatd by me.

                   

                  My flex-version is 3.2.0, imho the latest version.

                   

                  i read your post and work through, so, before i unload my module by button in mainapplication, i set the focus per "focusManager.setFocus(loadBtn);" away from my module. Also, i placed a dg on my mainApp with a dataProvider. Both won't fix my problem. in my example, there is no styles defined at all.

                   

                  i think, i haver to get the information from profiler, which reference pin my module inmemory, but i'm unable to locate it at this time.

                  The unloading works fine until i click on the dg or typing in some letters. Imho, there must be a procedure that will pin the module after getting some buttonDownEvents (or something else). But i'm not so deep in the framework to figure out the procedure for my self.....

                   

                  Can you give me further information, please.

                   

                  thank you for your helpful answers. unfortunately i found no solution for my problem.

                   


                  Frank

                  • 6. Re: Alert or Popup in Modules
                    Frank F._ Level 1

                    Alex,

                     

                    i found in your blog a workshop for detecting leaks with profiler. i really work hard but i didn't found a single id. All ids are listet again in an upper node. So, as you describe, thats not the objects who cause the leak.

                     

                    i also find the 3.4SDK and update my system. but nothing changes.

                     

                    if i have in the example a huge application with a lot of timers, listeners and so one, i would say, that i did an error.

                    But in my minimal-example nothing of these tihngs are implemented.

                     

                    Either, there is a bug (after a few tests, button, chackbox, radioButton, label cause no error, textInput and datagrid cause the error, but textInput inherit from UIComponent and datagrid from ListBase / DataGridBase, while a button inherit also from UIComponent and cause no error.) or i did a generall failure.

                     

                    The failure appears after clicking or typing into the component while the component has the focus. Is there anything, wich i should generally unregister?

                     

                    Thanks

                    Frank

                    • 7. Re: Alert or Popup in Modules
                      Frank F._ Level 1

                      Alex,

                       

                      i can't believe it.

                      my problem is solved with the sdk 3.4. Switching back to 3.2, the problem comes back!.

                       

                      the module is removed after clicking into the datagrid.

                      but, if i typing something in, the module will be removed until i typing a letter somewhere into the application. can i control this beavior by code?

                       

                      Thank you!

                      Frank

                      • 8. Re: Alert or Popup in Modules
                        Flex harUI Adobe Employee

                        You can try setting focus somewhere else in the app, but it might be the player issue described in the post about unloading modules.  The profiler can help you figure it out.

                         

                        Alex Harui

                        Flex SDK Developer

                        Adobe Systems Inc.

                        Blog: http://blogs.adobe.com/aharui

                        • 9. Re: Alert or Popup in Modules
                          Frank F._ Level 1

                          thank you