Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Big memory leak on linux headless build.

Discussion in 'Linux' started by Paradoks, Apr 7, 2019.

  1. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    Hello,

    I am building my masterServer for my multiplayer game on linux with headless mode.
    Everything goes well the first few hours, i monitor with htop, my MasterServer is at 3.5-4% of the memory used.
    Then after a few hours, it is at 63% wich cause the MasterServer to not work properly anymore.
    I removed from my build everything i heard could cause a leak: camera, canvas, OnGUI(), update() etc...

    Did you hear something similar, what do you think i could ?
    Any suggestion is welcome.

    thanks
    here is the game:
    http://www.adversator.com/
     
  2. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    @natosha-bard
    I know a few persons that have the same problem as me.
    I can't be the only on this forum that is hosting his online game on a linux VPS.
    Could you lend me a hand please ?
     
    adammpolak likes this.
  3. ShantuApps

    ShantuApps

    Joined:
    Apr 25, 2016
    Posts:
    14
    one of my panel was attached to LoadingManager Script, where following update code was written. As you can see Text was appended wrongly += with loading string over and over, i have memory leak in headless mode. Although this panel is never opened in headless mode but this is referenced in main canvas. To find out, i have set break point in all update methods in the solution and by the help of Allah i could find out this after several months. I am using unity 2019.1 editor with let me debug all the scripts also unity network codes.

    Code (CSharp):
    1. void Update()
    2.     {
    3.         if (gameObject != null && gameObject.GetComponent<Text>() != null && gameObject.activeSelf)
    4.         {
    5.             if (DateTime.Now.Millisecond > 500)
    6.             {
    7.                 gameObject.GetComponent<Text>().text += "Loading....";
    8.             }
    9.  
    10.         }
    11.     }
    Long story short: check all of your update methods closely. Remove string appends or Ressourse.load() from update method.
     
  4. PixelJ

    PixelJ

    Unity Technologies

    Joined:
    Nov 1, 2018
    Posts:
    216
  5. andrews_unity

    andrews_unity

    Unity Technologies

    Joined:
    Dec 11, 2015
    Posts:
    264
    Can you also the bug case# here in this thread
     
    Last edited: Aug 7, 2019
  6. Sallaxer

    Sallaxer

    Joined:
    Jun 18, 2016
    Posts:
    1
    Has anyone managed to fix the problem? Still relevant as of 2019.4.13f1
     
    adammpolak likes this.
  7. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    34
    Tracking down a memory leak in a 2018.4.31f1 game's headless Linux build. Let me know if any tips on common causes (theory right now is something around Resources.Load of our levels, but haven't narrowed it down yet).
     
  8. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    That's an old thread, I don't remember well how I managed to get ride of the leak, I think it was related to a InvokeRepeating.
    So i removed all the InvokeRepeating and replaced them with loops in Update.
    "I think" it did the trick for me, but i changed so many things at this time, that i am not even sure.
    But as ShantuApps mentioned above, it can be your code too.
    My very first step now, would be, to make a build on Windows and monitor it to see if the leak happens on Windows too.
    Launching the server in Editor to check with profiler could be good too.
    Hope it helps a little.
     
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,159
    You can also trigger memory snapshots from code with this API (taking the 2018.4 documentation page for @bcjordan's case) and load these into the Memory Profiler package (in e.g. an empty Unity project in any Unity Version that is at least as old as the captured player, and in any version of the Memory Profiler package, i.e. 2018.4 & 0.2.10-preview.1, or 2022 and 1.0.0. Newer versions might make this easier to track down)