1 Reply Latest reply on Apr 6, 2007 4:48 PM by Newsgroup_User

    Director Memory Leak Issue- Hopefully for the dev team to read and remedy in the next version

    Level 7
      Results of property accessing or commands performed on objects that are not
      assigned to variables are not being released.
      This leads to a memory leak, if the result is something else than an
      integer, float (not double) or symbol.

      To replicate the issue, attach the following script to any sprite, click on
      it, and check the memory usage increasing:

      on exitFrame me
      go to the frame
      end

      property s
      on beginSprite me -- create a +50MB string.
      s="0123456789"
      repeat while s.length<50*1024*1024
      s=s&s
      end repeat
      end

      on mouseUp me
      s.char[1..s.length] -- get all chars of the string.
      put result() -- the result should be stored here, but it is not.
      end

      Alternatively, with Xtrema [ http://xtrema.rtr.gr ] you can perform the
      check from the message window:

      s=_s().resize(50*1024*1024, "abcd").string -- generate a 50 MB director
      string
      s.char[1..s.length] -- using this command results to the memory leak.


      The above code should never be found in a real world app -since it just
      returns a value and performs no modifications- but it was the simpler method
      to demonstrate the leak.
      Commands on objects that do perform modifications and also return values
      will lead to memory leaks, if the result is not assigned to a value.


      Checked on XP 8.5 & MX2004 and on OSX 10.3 MX2004

      ---

      Tech: Dev Team Note, based on XDK.

      The resultValue of the getProp and especially the resultValue of the callptr
      of the callHandler calls should be assigned to the global result value, if
      no value to receive the result has been used in the lingo code.