11 Replies Latest reply on Mar 27, 2007 1:00 AM by Newsgroup_User

    detecting a memory leak

    Level 7
      I have a game catalogue implemented as SWF which runs other flash games
      loading them into itself.
      It works. Problem is that it gets slower and slower every time another game
      is loaded and them I have a system message that virtual memory is out.
      Running every game separately as well as running the catalogue without
      calling games through it does not cause this problem no matter how long a
      game is played and how many time it is restarted.

      How shall I find where the memory leak is?


        • 1. Re: detecting a memory leak
          Level 7
          You can try to look in debug mode if data is stored in the _level0 or
          _root or _global in your "parent" movie. I don't know if getBytesTotal
          function will give you the exact memory use of flash programming but it
          may be worth a try/look.

          A good way to avoid memory leaks is to build always a sub branch for
          generated clips (the dirty way is to put them in _level0). When you
          don't need them anymore you can "cut" the parent clip (i.e. jump to an
          empty frame) and the memory should become free/unallocated.

          I often find leaks in debug mode. Sometimes clips with the same name
          generated in one timeline can create unaccessible instances that can
          cause memory problems.
          • 2. Re: detecting a memory leak
            Level 7
            I doubt it's a memory leak. My guess would be that you're not unloading old
            games as new ones are loaded in.

            --
            Dave -
            Head Developer
            www.blurredistinction.com
            Adobe Community Expert
            http://www.adobe.com/communities/experts/


            • 3. Re: detecting a memory leak
              Level 7
              I do not unload it indeed. Do I need to? I thought that loading a new SWF
              into the same level displaces the previos swf.
              Actually I use this catalogue for a long time but problems with this "memory
              leak" popped up recently after I introduced a shared object into it

              "DMennenoh **AdobeCommunityExpert**" <dave@blurredistinction.com> wrote in
              message news:eu8b3g$dn3$1@forums.macromedia.com...
              > I doubt it's a memory leak. My guess would be that you're not unloading
              old
              > games as new ones are loaded in.
              >
              > --
              > Dave -
              > Head Developer
              > www.blurredistinction.com
              > Adobe Community Expert
              > http://www.adobe.com/communities/experts/
              >
              >


              • 4. Re: detecting a memory leak
                Level 7
                I checked HELP and it says:
                =====================
                When you load a SWF file, you can specify any level number and you can load
                SWF files into a level that already has a SWF file loaded into it. If you
                do, the new SWF file will replace the existing SWF file. If you load a SWF
                file into level 0, every level in Flash Player is unloaded, and level 0 is
                replaced with the new file. The SWF file in level 0 sets the frame rate,
                background color, and frame size for all other loaded SWF files.
                ======================
                I load into level 0 - do I still need to unload?

                "aa" <A@aa.com> wrote in message news:eu8m7p$rfl$1@forums.macromedia.com...
                > I do not unload it indeed. Do I need to? I thought that loading a new SWF
                > into the same level displaces the previos swf.
                > Actually I use this catalogue for a long time but problems with this
                "memory
                > leak" popped up recently after I introduced a shared object into it
                >
                > "DMennenoh **AdobeCommunityExpert**" <dave@blurredistinction.com> wrote in
                > message news:eu8b3g$dn3$1@forums.macromedia.com...
                > > I doubt it's a memory leak. My guess would be that you're not unloading
                > old
                > > games as new ones are loaded in.
                > >
                > > --
                > > Dave -
                > > Head Developer
                > > www.blurredistinction.com
                > > Adobe Community Expert
                > > http://www.adobe.com/communities/experts/
                > >
                > >
                >
                >


                • 5. Re: detecting a memory leak
                  anonymous thing
                  "I load into level 0 - do I still need to unload?"

                  - in that case no. But it's better way to load content not on level0. You can also try to load into a movieClip(this is a better technique)

                  your real problem migth came from listener and reference that you don't deleted before you load the next swf :

                  -- remove all Mouse listener you used
                  -- remove all Key listener you used
                  -- delete all object reference(mc, class ......)
                  • 6. Re: detecting a memory leak
                    Level 7
                    That might be relevant indeed for I use Key listener
                    Are you saying that if I replace an SWF which has a Key listener with
                    another SWF which also has a Key listener using loadMovieNum("SWF",0) ,
                    the first Key listener does not get destroyed?

                    "anonymous thing" <webforumsuser@macromedia.com> wrote in message
                    news:eu8s35$5ms$1@forums.macromedia.com...
                    > "I load into level 0 - do I still need to unload?"
                    >
                    > - in that case no. But it's better way to load content not on level0. You
                    can
                    > also try to load into a movieClip(this is a better technique)
                    >
                    > your real problem migth came from listener and reference that you don't
                    > deleted before you load the next swf :
                    >
                    > -- remove all Mouse listener you used
                    > -- remove all Key listener you used
                    > -- delete all object reference(mc, class ......)
                    >


                    • 7. Re: detecting a memory leak
                      kglad Adobe Community Professional & MVP
                      correct. i don't know any way to destroy the listener, but you can stop it from listening by using removeListener before your loadMovieNum() or loadClip statement.
                      • 8. Re: detecting a memory leak
                        Level 7
                        To which particular comment your comment is relevant?
                        "kglad" <webforumsuser@macromedia.com> wrote in message
                        news:eu99um$nfl$1@forums.macromedia.com...
                        > correct.


                        • 9. Re: detecting a memory leak
                          Level 7
                          I looked at the processes in Task Manager.
                          The cataloge.exe which is a windows projector file published by FLASH-8,
                          which is 2.2Mb takes 21 Mb of memory.
                          When I load into it a 130K swf, the process name is still cataloge.exe and
                          it takes 8M.
                          However when I several times reload it using Key listener the memory
                          consumption raises up to 180M which slowly goes down when I stop reloading.
                          So I have a memory leek?
                          Could key listeners cause it?


                          • 10. Re: detecting a memory leak
                            kglad Adobe Community Professional & MVP
                            i was replying correct to:

                            Are you saying that if I replace an SWF which has a Key listener with
                            another SWF which also has a Key listener using loadMovieNum("SWF",0) ,
                            the first Key listener does not get destroyed?
                            • 11. Re: detecting a memory leak
                              Level 7
                              Thanks, good to know such details.
                              Do you think Key listeners leftovers can eat that much memory?

                              "kglad" <webforumsuser@macromedia.com> wrote in message
                              news:eu9qu2$dlh$1@forums.macromedia.com...
                              > i was replying correct to:
                              >
                              > Are you saying that if I replace an SWF which has a Key listener with
                              > another SWF which also has a Key listener using loadMovieNum("SWF",0) ,
                              > the first Key listener does not get destroyed?
                              >
                              >