5 Replies Latest reply on Sep 21, 2011 4:32 PM by kglad

    Slower and slower over time

    JeffKershner

      I have a dashboard I created using Flash CS5 using CS5.5 and ActionScript 3.  It seems that while this dashboard is running, the FPS gets slower and slower over time (over several hours).  I am thinking that I might have a memory leak but I am not sure how to find out.

       

      The project is a Flash Projector exe that loads 8 independent swfs.

       

      Each swf file essentially calls a  web service and gets XML data.  They then dynamically create a bunch of TextFields, assigns an event listener (Event.ENTER_FRAME) and animates across the screen. 

       

      When the TextField goes off the screen, I clean up the Text field by removing the EventListener, removing the TextField and setting the TextField to null.

       

      I am new to flash.  What might I be doing wrong?  Any suggestions where to look?

       

      thanks,

      --Jeff

        • 1. Re: Slower and slower over time
          kglad Adobe Community Professional & MVP

          the most common problem causing that (and requiring hours for the problem to become appreciable) is creating an increasing number of objects and failing to gc unneeded objects.

          • 2. Re: Slower and slower over time
            JeffKershner Level 1

            This is what I believe is happening.  I don't see what I might not be freeing.  I remove all event listeners and remove the TextFields from the display list.  Is there anything else I need to do?

             

            Currently I am displaying the frame rate.  I see a frame rate starting at 30 and going down to 8 after several hours.

             

            I also just started to display the memory:

            tf.text = Number( System.totalMemory / 1024 / 1024 ).toFixed( 2 ) +' Mb';

             

            I am interested to see if when the FPS goes down to < 10, if the memory is much larger.

             

            Are there any tools that might help debug what might be happening?

            • 3. Re: Slower and slower over time
              kglad Adobe Community Professional & MVP

              i don't know of any tools that will help you pinpoint the problem.  but you need to do more than just remove objects from the display list and remove listeners:  you need to null all object references.

              • 4. Re: Slower and slower over time
                JeffKershner Level 1

                Yeah, like I said in my original post:

                When the TextField goes off the screen, I clean up the Text field by removing the EventListener, removing the TextField and setting the TextField to null.

                 

                If you have any other suggestions, point them my way.  Thanks!

                • 5. Re: Slower and slower over time
                  kglad Adobe Community Professional & MVP

                  again, that's not necessarily enough:  you need to null ALL object references.

                   

                  if you did that all that, your objects would eventually be gc'd long before your app started to slow.