Search Unity

Unity Editor VERY high memory usage nowhere to be found in profiling tools, how to debug?

Discussion in 'Editor & General Support' started by oxysofts, Aug 24, 2020.

  1. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    The commit memory of the Unity Editor slowly rises over the course of several hours as I am working on the game. In one of our game maps (with several scenes open) on a fresh boot, the commit memory is at 4.2GB while 'working set' is at 2.8GB. My system frequently runs out of memory when I'm working on our game and everything goes batshit for a moment, usually resulting in the editor and/or my IDE crashing.

    I am forced to work in a minimal test setup most of the time because I simply cannot work for long periods of time inside of our actual game maps, as I have a much higher chance of running out of memory. However I am increasingly having to work in our actual maps due to game content that has to be worked on and tested in these specific maps, and naturally I can't always remain in these stripped down test environment. This morning, in the span of 1 hour the commit memory has reached 9GB which caused Unity and some other apps to crash, including my IDE. I haven't been able to pin-point any particular action which causes the memory to rise, it just seems to slowly creep up over time as I work on the code, cause domain reloads, play and stop the game, etc.

    Several times I have attempted to investigate in both the profiler and the new memory profiler package, and I can never see anything out of the ordinary. Nothing jumps out, and the memory shown in these profiling tool always reflect very accurately the actual memory shown in the 'working set' column of the Windows Resource Monitor. I have read in another forum post by Unity Developer Martin that memory allocated by plugins distributed as pre-compiled DLLs cannot be tracked. Nevertheless, it would be difficult to start removing plugins and see if that fixes it since many of these plugins are integral to our game.

    What are my options here?
    Thanks!
     
    Last edited: Aug 24, 2020
    futurlab_xbox likes this.
  2. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    507
    Hi @oxysofts,

    Have you checked how the actual memory is distributed analyzing the Editor's Memory, using the Unity Profiler?


    I hope this helps you to find the source of the memory leak!
     
  3. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    I have tried both the Unity Profiler and the new Memory Profiler, and only the working memory seems to be shown or tracked in these tools.

    I took some images while in play-mode just now to better convey what is going on.

    Here is the row for Unity in Process Explorer

    upload_2020-8-25_14-8-49.png

    Next, this is a sample taken in the Unity Profiler:

    upload_2020-8-25_14-15-5.png

    As we can see, the memory pretty much matches the working set column.
    Next, I went into the new Memory Profiler and took a snapshot.

    upload_2020-8-25_14-16-33.png

    Again, this appears to be the same contents shown in the Unity Profiler, but with a nicer presentation.
    Nothing out of the ordinary again. Perhaps the other views of the Memory Profiler could be more revealing, but I'm not too sure how to interpret the data shown in those views. I can share the snapshot as well if necessary.
     
    futurlab_xbox likes this.
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    This sounds like you are indeed using plugins which could be interesting to investigate with native platform Profilers? I know xCode instruments allows for some memory profiling, maybe PIX does allow for it on Windows?

    While I'm compiling something of a nicer write-up for the manual, you might wanna check this post and the memory map, because the view you screenshoted only contains memory associated with Objects.