9 Replies Latest reply on May 15, 2008 7:02 AM by kglad

    Vars and memory cleanup

    ooba
      in a method I am creating dynamically created vars based on the 'frame' + _currentframe set keep track of if the user has been on the frame before.

      It is working on and off. By using trace statements I can see that the var is created and set then when i navigate away and back it is still there but if i take a little time navigating away then back the var gets recreated because it does not see it.

      My only thought on this is that garbage collection is occuring. Is this correct? Any thoughts?
        • 1. Re: Vars and memory cleanup
          kglad Adobe Community Professional & MVP
          show the code you're using to set your variable.
          • 2. Vars and memory cleanup
            ooba Level 1
            Note the following code resides inside of a method.
            • 3. Re: Vars and memory cleanup
              kglad Adobe Community Professional & MVP
              there's no problem with the code you showed. if there's other code where your variable appears and it's not on the right-hand-side of an assignment operator (=), that may be the problem.
              • 4. Re: Vars and memory cleanup
                ooba Level 1
                kglad,
                Thanks for looking at this issue with me.

                As for additional code, there is none that makes any reference to the variable. I check and see if it exists in an if condition as posted above if it does not exists then it will lets say call a method playA(). Else it will call a method showButDontPlayA().

                Nothing else makes a reference to it. So I was thinking that because its being created inside of a method it gets cleaned up right away once im out of the method.

                Thinking of creating an array var at the top and then the method call can just add to the array since im keeping track of frames that are viewed. I dont think a var created at the top level can be cleaned out since it was not dynamically created.

                Do you know of any links to information on variable persistence that you know of that are direct and not dozens of pages of blah blah blah information?

                thanks again.
                • 5. Re: Vars and memory cleanup
                  kglad Adobe Community Professional & MVP
                  variables are not gc'd by flash unless they are local to a function/method and prefixed with var in a declaration (which you've just stated doesn't exist) or they are local to a timeline/movieclip that is removed.
                  • 6. Re: Vars and memory cleanup
                    ooba Level 1
                    Thanks for the clarity on the gc feature. I'm a bit baffled as my situation is none of the ones you have listed. The method that is called is on the main stage timeline and spans over all frames.

                    I'll have to play around a little more with it and if all else fails try a different way of dealing with this. Thanks again kglad.
                    • 7. Re: Vars and memory cleanup
                      kglad Adobe Community Professional & MVP
                      you're welcome.
                      • 8. Re: Vars and memory cleanup
                        ooba Level 1
                        I just found the issue.

                        Something about Flash I dont like. If you use ActionScript to place items on the stage, then when you try and find references to code such as my variable and it exists in a library item, Flash will NOT list the item in the Movie Explorer.

                        Only items that where manually placed on the Stage will show up in the listing for the Movie Explorer.

                        I did have a reference to the variable that was = and not ==.

                        Thanks a bunch kglad :)
                        • 9. Re: Vars and memory cleanup
                          kglad Adobe Community Professional & MVP
                          you're welcome.