14 Replies Latest reply on Mar 2, 2014 4:51 AM by sunil patrapati

    Memory limitations in the flash player

    KrisKohlstedt

      I've been running into some memory limitations in a flex application that I'm working on.  As a test I wrote the code below to try and determine what the true memory limitations of a flex application running in the flash player are.  What I've found is the following.  On both the windows and linux machines there is a total of 4G of space available and in none of these cases was the OS near hitting the physical memory limit.

       

      Max memory usage on various configurations:

       

      flash player 10 on windows = ~650M

      flash player 9 on windows = ~800M

      flash player 10 on linux = unlimited (I was able to get up to 2.5G without any problems)

       

      Has anyone else run into these limitations?  Can anyone comment on possible work arounds to these limitations or provide any insight on why the flash player would have an artificial memory limit below what the OS can provide?

       

       

      In the following application each button click takes up about 100M making it fairly easy to see at what point the flash player is crapping out.

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
           xmlns:mx="http://www.adobe.com/2006/mxml"
            minHeight="600" minWidth="800">

           <mx:Script>
               <![CDATA[
                       import mx.formatters.NumberFormatter;
             
                       var outer:Array = new Array(1000);
                       var outerCnt:int = 0;
                       private const MBYTE : int = 1024 * 1024;
                   private function onButtonClick():void {
                       var inner:Array = new Array(5000000);
                       var formatter:NumberFormatter = new NumberFormatter();
                       formatter.useThousandsSeparator = true;
                       var cnt:int = 0;
                       for(var i:int=0;i<50000000;i++) {
                           inner[cnt++] = "testsstringtestsstringtestsstringtestsstringtestsstringtestsstringtestsstringtestsstring testsstringtestsstring";
                             
                       }
                     
                       outer[outerCnt++] = inner;
                     
                       text.text = formatter.format(flash.system.System.totalMemory/MBYTE);
                   }
                

               ]]>
           </mx:Script>
           <mx:Button id="btnConfirmSubmit" click="onButtonClick()" label="click me"/>
           <mx:Text id="text"/>

      </mx:Application>

        • 1. Re: Memory limitations in the flash player
          Flex harUI Adobe Employee

          What error did you get at the limit?  System.totalMemory is not the same as total process memory.  See my blog for details?

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

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

          • 2. Re: Memory limitations in the flash player
            KrisKohlstedt Level 1

            In some cases I get the stack trace below and in other cases the application just crashes with no flex stack trace at all.  Was there something specifically related on your blog that I should take a look at?  Thanks.

             

             

            Error: Error #1000: The system is out of memory.

                     at global$init()
                     at flash.display::MovieClip/nextFrame()
                     at mx.managers::SystemManager/deferredNextFrame()
                     at mx.managers::SystemManager/preloader_initProgressHandler()
                     at flash.events::EventDispatcher/dispatchEventFunction()
                     at flash.events::EventDispatcher/dispatchEvent()
                     at mx.preloaders:: reloader/timerHandler()
                     at flash.utils::Timer/_timerDispatch()
                     at flash.utils::Timer/tick()

            • 3. Re: Memory limitations in the flash player
              Flex harUI Adobe Employee

              There's a post on how to use the profiler that explains the difference between System.totalMemory and process memory.  There may also be a limit on how much memory plug-ins can use, but I'd say that if you've used up 500MB, that's quite a bit and some sort of memory management strategy is in order.  Otherwise, if the customer is using your app along with Excel and some other biggies, there'll be lots of thrashing.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

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

              • 4. Re: Memory limitations in the flash player
                KrisKohlstedt Level 1

                Its a big application, there is no doubt about that but regardless we are trying to figure out why the flash player limits the amount of memory that the application can use.  Especially when the machine itself has plenty of memory available.  Was this by design?  Is there any known workaround?  Is this something that is expected to be fixed in upcoming releases?

                • 5. Re: Memory limitations in the flash player
                  Flex harUI Adobe Employee

                  Like I said, System.totalMemory is not the same as process memory (and can be a fraction of total process memory).  What kind of process memory do you see when System.totalMemory is at 500MB?  AFAIK, the player has no official limits but the plug-in browser hosts might.

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

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

                  • 6. Re: Memory limitations in the flash player
                    KrisKohlstedt Level 1

                    The process memory seems to stay fairly well in line with what totalMemory is reporting.  For example when the test application that I posted earlier first launches the browser process takes around 200M.  As I force the flex app to conume more memory the amount of memory that flex/flash reports being i n use and the amount that the process is actually using seem to grow in line with each other.  So when flex/flash reports 300M in use the browser process is at about 500M and when flex/flash reports 500M the process is at 700M.

                     

                    The reason I was suspecting that the flash player was the limitation is because we see this same behavior in firefox, crome and IE.  I suppose its possible that under the hood somehow they all share a plugin framekwork which is imposing the limitation.

                     

                    Thanks for the information, any other thoughts or possible workarounds (I'm not hopeful here) are appreciated.

                    • 7. Re: Memory limitations in the flash player
                      Flex harUI Adobe Employee

                      Each browser has its own plug-in architecture.  Each browser may be imposing limits.  The only workarounds I would suggest are ones that would get your app to run in less than 200MB.  Unless you're hosting on a kiosk, that's quite a load to take against other apps running on the same system.

                       

                      Alex Harui

                      Flex SDK Developer

                      Adobe Systems Inc.

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

                      • 8. Re: Memory limitations in the flash player
                        KrisKohlstedt Level 1

                        Yep, we are running the app on dedicated machines.  In the end what this means is that the size of the applications that can be developed in flex is somewhat limited.  Look for example at eclipse itself, it is currently running on my machine and using over 1G of memory.  I'm running another fat client Java application that often takes well over 1G of memory.  While that is a lot of memory to be using, it is the requirement of applications with enough functionality that they will use a lot of memory to operate.  Perhaps flex/flash wasn't designed for that level of application.

                         

                        In any case, thanks again for the information.

                        • 9. Re: Memory limitations in the flash player
                          Flex harUI Adobe Employee

                          It probably isn't a design issue.  We have to live in browsers.  Did you try the standalone player or AIR?

                           

                          Alex Harui

                          Flex SDK Developer

                          Adobe Systems Inc.

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

                          • 10. Re: Memory limitations in the flash player
                            sunil patrapati

                            hi,

                             

                            I am facing the exact same issue even in Adobe Air. Here is the code snippet. Any help/input would be of great help.

                             

                             

                            <?xml version="1.0" encoding="utf-8"?>
                            <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                                                                 xmlns:s="library://ns.adobe.com/flex/spark" 
                                                                                 xmlns:mx="library://ns.adobe.com/flex/mx">
                                      <fx:Script>
                                                <![CDATA[
                                                          import mx.events.FlexEvent;
                            
                                                          private var byteArray:ByteArray = new ByteArray();
                                                          protected function button1_clickHandler(event:MouseEvent):void
                                                          {
                                                                    var count:int = 1048576*600;
                            
                                                                    for(var i:uint = 0; i<=count; i++)
                                                                    {
                                                                              try{ 
                                                                                     byteArray.writeBoolean(true);
                                                                              }catch(e:Error){
                                                                                    trace(e.message);
                                                                                    break;
                                                                              }
                                                                    }
                                                          }
                            
                                                ]]>
                                      </fx:Script>
                            
                                      <s:Button click="button1_clickHandler(event)"/>
                            
                            </s:WindowedApplication>
                            
                            
                            • 11. Re: Memory limitations in the flash player
                              Flex harUI Adobe Employee

                              What error did you get and at what memory level?

                              • 12. Re: Memory limitations in the flash player
                                sunil patrapati Level 1

                                hi,

                                 

                                Thanks! I am getting "Error #1000: The system is out of memory."  when it reahces around 546 MB.

                                 

                                Other details:

                                FlexSDk : 4.6.0

                                Adobe Air: 3.1

                                Published as: Captive Runtime

                                OS: win7 32 bit

                                Installed Ram: 4 GB

                                Virtual Memory: 3100 MB

                                 

                                TaskManager.jpg

                                 

                                Please let me know if you need any other info.

                                 

                                thanks

                                Sunil.P

                                • 13. Re: Memory limitations in the flash player
                                  Flex harUI Adobe Employee

                                  You might want to file a bug at bugbase.adobe.com.  Or try a later version of AIR.

                                  • 14. Re: Memory limitations in the flash player
                                    sunil patrapati Level 1

                                    I tried with Adobe Air V4, but still the crash issue persists. As suggested by you I will rasie a bug.

                                     

                                    thanks & Regards

                                    Sunil.P