Results 1 to 4 of 4

Thread: Possible memory leak

  1. #1

    Possible memory leak

    After repeatedly spawning and deleting objects, the "Over 2.x Ram" warning appears.(Followed by performance hits eventually as ram usage goes even higher.)

    The order of events taking place is one of the following:
    - Spawn a bunch of objects, say 100. Then delete all 100, and spawn another 100, then delete, etc.
    - Spawn a bunch of objects via a script, save and reload the script, which resets the board to empty or whatever it was before those were spawned. Repeat this a bunch, over time the ram warnings start.

    I opened up task manager to observe the memory usage of TTS as I spawned things. Spawning objects obviously increases memory usage, but deleting them never seemed to help the memory usage go back down.

    I did a test and spawned a bunch of objects while adding a bunch of garbage data to them.

    Code:
    function addGarbage(obj)
        obj.setVar('garbage_0', 999999)
        obj.setVar('garbage_1', 999999)
        obj.setVar('garbage_2', 999999)
        obj.setVar('garbage_3', 999999)
        obj.setVar('garbage_4', 999999)
        obj.setVar('garbage_5', 999999)
        obj.setVar('garbage_6', 999999)
        obj.setVar('garbage_7', 999999)
        obj.setVar('garbage_8', 999999)
        obj.setVar('garbage_9', 999999)
    end
    The memory usage went up extremely quick with this, and deleting the spawned objects didn't seem to help free up the memory used. I tried adding a second function to nil those variables, but that didn't seem to help either.

    Code:
    function onObjectDestroyed(obj)
        obj.setVar('garbage_0', nil)
        obj.setVar('garbage_1', nil)
        obj.setVar('garbage_2', nil)
        obj.setVar('garbage_3', nil)
        obj.setVar('garbage_4', nil)
        obj.setVar('garbage_5', nil)
        obj.setVar('garbage_6', nil)
        obj.setVar('garbage_7', nil)
        obj.setVar('garbage_8', nil)
        obj.setVar('garbage_9', nil)
    end
    Completely restarting the game seems to be the only fix. Exiting to the main menu only frees up a small amount of memory, but not all that was accumulated over time.

  2. #2
    Join Date
    Feb 2016
    Location
    Sweden
    Posts
    77
    If you are storing them in tables then that might be the issue, if not then there's a memory leak on TTS's side most likely.

  3. #3
    Nope no tables were being used. The objects were spawned without assigning their reference to anything. The only info on the objects is the garbage variables.

  4. #4
    Join Date
    Jul 2015
    Posts
    159
    Quote Originally Posted by nyro View Post
    The order of events taking place is one of the following:
    - Spawn a bunch of objects, say 100. Then delete all 100, and spawn another 100, then delete, etc.
    - Spawn a bunch of objects via a script, save and reload the script, which resets the board to empty or whatever it was before those were spawned. Repeat this a bunch, over time the ram warnings start.
    Which is it or do you have to do both?

    Are you using Unity 4 or 5 branch of the game?

    What kind of objects are you spawning?

    Can you upload a workshop mod showcasing this with precise instructions?

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •