[Linux] Observations on memory use.

Discussion in 'Feedback' started by AoiBlue, Oct 12, 2020.

Thread Status:
Not open for further replies.
  1. AoiBlue

    AoiBlue Avatar

    Messages:
    406
    Likes Received:
    319
    Trophy Points:
    55
    Gender:
    Male
    I decided to take some time to do some observations on the memory use and noticed something interesting:
    After you enter and leave a place with player lots and then return to other parts of the game application memory does not return to normal usage after the scene change, like other scenes.

    This starts squeezing out the disk cache memory, and eventually squeezing infrequently used system programs into swap, thus causing severe performance problems, and eventual swap-wait hitches.

    This is a potential sign (not definite sign) of a specific memory leak protection in Unity's "Scene based" framework not being used. This is an extremely easy memory leak cleanup method.

    Simply attaching all objects created in scene that should be destroyed by the time the scene is exited, as attached to the primary scene object tree, as well as all objects accessing them, you can insure that when the scene object tree is destroyed, so is everything else. This helps mop up memory leaks during scene transitions, even if your in-scene object loading and unloading routines have a few leaks.

    Ideally the leaks should be taken care of directly, but this can help control any you don't catch with very little work beyond an initial script-based change to the code. After all, C# is very prone to memory leaks, and some of the leaks are beyond your control in 3rd party software and Unity itself. Expecting anyone to code perfect leak-free code in C# is an tall order at best, and impossible request at worst.
     
    AzazelReborn likes this.
Thread Status:
Not open for further replies.