Search Unity

Memory leak in the build but not in the editor.

Discussion in 'Editor & General Support' started by esenkaya, May 9, 2019.

  1. esenkaya

    esenkaya

    Joined:
    Jul 3, 2018
    Posts:
    2
    I am currently working on a rather large project that has gone through multiple developers, leaving a lot of unknown code for me to sort through. I have been spending a lot of time recently attempting to narrow down the cause of a memory leak, but I noticed that when I run the game in the editor, there is no issue with memory whatsoever. However, when I build and run the game, it crashes with an out of memory error within 5 hours. Due to the nature of the game, it has to be able to run for at least 10 hours per day. I was hoping someone might be able to point me in the right direction since I'm not exactly sure what could be causing the issue.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You're not giving enough information for anyone to reasonably point you in the right direction other than just general steps to take when investigating this kind of issue. For example, you should be looking at the profiler for the build compared to the editor, should be mentioning what platform and CPU type (x86 vs x86_64), what makes you think this is specifically a memory leak besides running out of memory, etc. You need to narrow down what scene(s) and what code or objects within the scene are the source of the memory leak, assuming it is even a memory leak at all.

    For all we know there is no memory leak, and your game as designed needs 5GB of memory which works fine in the editor, but will run out of memory in your 32 bit build because that's what 5GB of memory allocations does in a 32 bit build.
     
  3. esenkaya

    esenkaya

    Joined:
    Jul 3, 2018
    Posts:
    2
    I've looked at the profiler for both the editor and the build. The total system memory usage for the editor is constant at 2.90 GB, whereas the total system memory usage for the build begins at 0.50 GB and increases by 0.01 GB every 5 seconds until the out of memory crash.

    Platform: Windows
    CPU: x86_64

    I am operating under the assumption that it is a memory leak, as that is what the previous developer said he was looking for before he left. The increase in memory begins at launch which is a scene with a menu screen and no other objects. However, there are a number of scripts running in the background initializing cameras and projectors.