Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Memory increase over time in Empty projects

Discussion in 'Profiler Previews' started by ranch000, Aug 29, 2023.

  1. ranch000


    Mar 24, 2017
    Hello, We were facing memory issues in our live game. During analysis we observed gradual memory increase over consecutive snapshots even when the game is kept idle. So wanted to check if this behavior existed in a unity project with just an empty scene/sample scene. We profiled this in actual android device (development build with IL2CPP Scripting backend) using Unity 2020.3.46 & Unity 2022.3.4 and the observations are as in the attachments.

    1. Is the general memory increase over time intended/Unity leaks/memory profiler issue?
    2. Why do the 2022 snapshots show 1.73GB under Graphics?
    3. Why is there around 40MB increase in 2020(~150MB) vs 2022(~190MB) when profiled in android studio?
    4. Is there any constraint saying which profiler version is to used for profiling which unity version snapshots?

    Attached Files:

    VGap and unitylicense14 like this.
  2. antonk-unity


    Unity Technologies

    Oct 4, 2016

    1. When Memory Profiler takes a snapshot, it needs to capture type information. This might cause Mono/IL2CPP to allocate more memory (load and/or inflate types). There are improvements in 2023 LTS to reduce that value, but in 2020/2021/2022 you might see a minor increase in allocated memory. So, this is expected and we recommend taking the first snapshot as a "warmup" to reduce the effect if you compare multiple snapshots.
    2. That's how much memory OS reports to be allocated by gfx driver or the sum of all gfx resources. We apply some trickery to calculate this number, as graphics driver is a black box on most platforms. Might be a bug as well. It's hard to tell anything specific without seeing a detailed breakdown.
    3. There are too many possible reasons. It might be different settings, API selected (vulkan vs gles3), or something we in Unity made worse to make it bigger.
    4. When it comes to profiling, the newer Unity version - the better