8 Replies Latest reply on Jun 28, 2011 4:20 PM by PresidentCamacho

    Advice on Memory Management

    anynick Level 1

      I have a desktop application that is currently using between 150,000 - 175,000 MB of memory. The application needs to be able to drop almost all of that memory when the application is minimized to the task bar and have a resting memory footprint of about 15 MB. Does anyone have any suggestions on how to accomplish this? Could I write the main application as a child module and unload it when the application gets minimized (form my research on modules it seems they can be nearly impossible to pull out of memory)?


      Right now I am leaning towards writing an app in c# that will launch the AIR application as a child process and close the app when minimized to the task bar leaving only the 15 MB c# app in memory...when the user clicks the taskbar icon it will re-launch the AIR application. I would really rather not do that though because it will create a confusing two entries in the task manager.


      Any suggestions would be greatly appreciated.

        • 1. Re: Advice on Memory Management
          anynick Level 1

          To expand further...


          Is it possible to run an AIR application from within a c# application using the Flash Active X control? I have done this plenty of times with regular .swf files but I am not sure if it is possible with an AIR application that uses the "Extended Desktop" profile.

          • 2. Re: Advice on Memory Management
            Flex harUI Adobe Employee

            You can't use AIR-only APIs from Flash ActiveX control.  I'm not even sure

            an empty AIR app fits in 15MB.

            1 person found this helpful
            • 3. Re: Advice on Memory Management
              anynick Level 1

              Thanks for the reply. I was worried that even stipped down AIR app would be pretty hefty...any idea what the baseline mem is for an extended desktop app?


              I have been seriously considering stripping out all the AIR sepcific code, re-compiling it as a web app and just implementing it as a UI wrapped in c# using ExternalInterface. That way I could have better control over the memory issues...but that would require a lot of changes so I would really appreciate any other suggestions.

              • 4. Re: Advice on Memory Management
                Flex harUI Adobe Employee

                I don't know the number off-hand.  Best to try it yourself.


                Frameworks have a price.  That's why an MFC app is much bigger than one

                written right to the Windows API.

                • 5. Re: Advice on Memory Management
                  anynick Level 1

                  Yup, I understand that there is a trade off. I am willing to pay the large memory price to have the AIR UI but I just need a better way to control the memory usage when that UI is not needed. This application will be running for long periods of time and I can't have an app using 150+ MB of memory when it is just sitting idle in the system tray.


                  If I wrap it in an MFC app using the Flash Active X Control I can just dispose of the control when the app is inactive and the app memory usage will instantly drop to 15 MB. If there was a way to do this with AIR, perhaps loading/unloading all the UI as a module, that would be great.


                  Since my app only consumes 8 MB of memory on startup in the memory profiler yet consumes 120+ MB of memory on startup in the Task Manager there appears to be about 110MB of memory I do not have much control over, so I am increasingly doubtful that there will be an AIR only solution to my problem.

                  • 6. Re: Advice on Memory Management
                    Flex harUI Adobe Employee

                    Yeah, I'm not surprised that Task Manager for AR is about 120MB.  How about

                    just launching the AIR app from a native app when it is needed?  Or do you

                    need some sort of UI integration?

                    • 7. Re: Advice on Memory Management
                      anynick Level 1

                      Yeah, I think your suggestion is probably going to be my best bet. There is no real reason why they can not be seperate. I was initally leaning away from that solution becuse it would create multiple processes in the task manager, but I am thinking that is really not that big of a deal. Right now my app uses so much AIR specific code for the file system, sqlite, encrypted data store...and all that stuff is really elegantly instegrated into AIR, it would be a shame to have to ditch it.


                      I am gonna give this a go. Thanks again for all your input.

                      • 8. Re: Advice on Memory Management
                        PresidentCamacho Level 1

                        Awhile ago - Flash Player 9 days - I was working on an app that had integrated a C# WinForms UI with a Flash ActiveX control we were using for rendering content.


                        The biggest pain of that project was certainly back-and-forth interaction between the WinForms app and the ActiveX control - it was an extra pain every time to have to funnel all your calls through the ExternalInterface, marshal, dispatch back etc.  It was ugly, but it worked.  The biggest headache was probably the ActiveX control behaving very strangely with regards to focus - especially for drag-n-drop.


                        For your purposes - just using the native code as a launcher and background monitor - it seems like you won't have to worry about that much communication to AS3, sidestepping a lot of those headaches.