8 Replies Latest reply on Jan 11, 2011 9:57 AM by Roland684

    Get free/used memory info

    Roland684 Level 1

      I'm writing code for a system that is very limited in it's memory. I've written some code to cache the data and movieclips used, but eventually I'll need to free some memory before I run out (and flash is terminated)

      Is there a way to find out
      - how much memory flash/my .swf is using in total?
      - how much memory is free?
      - how much memory an object or movieclip (including it's children) occupy?

      I'm looking for something to decide wether or not I should release some memory. it doesn't need to be very precise, just anything I can use as an indicator in actionscript 2.0

      I've found that in Flash Lite I can use

      Code:
      fscommand2("GetTotalPlayerMemory")
      fscommand2("GetFreePlayerMemory");

      but unfortunately I'm not using Flash Lite and these commands don't seem to exist in flash 7+.

       

       

      Is there anything I could use?

        • 1. Re: Get free/used memory info
          kglad Adobe Community Professional & MVP

          as3 has a few properties of the System class you can use.  just create an as3 swf with the needed memory checking code and have it load your as2 file for development purposes.

          • 2. Re: Get free/used memory info
            Roland684 Level 1

            With your suggestion I can calculate how much memory known data occupies (at design time). Unfortunately I do not know what will be loaded. It will be tekst and images, but at design-time I do not know how much text or how many images.

             

            Even worse: I do not know how much memory will be available. This can vary greatly from run to run.

            • 3. Re: Get free/used memory info
              kglad Adobe Community Professional & MVP

              what would you do about it if your app is running on a problematic machine?

              • 4. Re: Get free/used memory info
                Roland684 Level 1

                The application is much like a browser: Pages (with text, images and some interactive elements) are defined on a server. The swf renders these pages and lets you navigate them.

                When enough memory is available I can keep previous pages in memory, so revisiting a pages and reusing images does not require them to be reloaded (which can take more than 10 seconds for a complex page).

                When memory is low, pages (except the current page) can be removed from the cache and they'll have to be reloaded when the user revisits them.

                 

                If I do not remove old pages/images from memory, eventually there will be a moment the swf runs out of memory and is killed. But if I remove pages too soon, revisiting them will be a wait. We've already seen situation where I can hold only 3 pages in memory simultaniously. It depends on the complexity of the page and the availablity of memory. As long as there is enough memory for 1 page, it'll work.

                 

                Basically I want to do as much caching as possible. The problem is finding out how much is possible.

                • 5. Re: Get free/used memory info
                  kglad Adobe Community Professional & MVP

                  if this is a web based app, continue using the as3 loader/system swf when you deploy your app.

                  • 6. Re: Get free/used memory info
                    Roland684 Level 1

                    it's an application running on a STB. actionscript 3.0 is not available.

                    • 7. Re: Get free/used memory info
                      kglad Adobe Community Professional & MVP

                      i don't know what stb means to you but if as3 is not available you're out of luck.

                      • 8. Re: Get free/used memory info
                        Roland684 Level 1

                        set-top box.

                         

                        I could get the amount of free memory from the OS and inject it into actionscript, but this is not very reliable because of flash's garbage collection which may not run or not release any memory back to the OS.