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

Unity Reservered Memory keep Increasing

Discussion in 'Editor & General Support' started by rodimus_strom, Apr 24, 2021.

  1. rodimus_strom

    rodimus_strom

    Joined:
    Oct 26, 2012
    Posts:
    3
    Hello,
    I'm facing an issue related to memory.

    Code (CSharp):
    1.  long allocated = UnityEngine.Profiling.Profiler.GetTotalAllocatedMemoryLong() / BYTES_MB;
    2. long reserved = UnityEngine.Profiling.Profiler.GetTotalReservedMemoryLong() / BYTES_MB;
    3. uitext.text = System.String.Format("{0}/{1} mb", allocated, reserved);
    I'm using this code to print the memory usage. So unity version after 2018.4.29 reserved memory is keep increasing when change scene or reload scene due to this game is getting slower after sometime. This issue is not in 2018.4.29 but after this in all version I'm facing this issue. I used MemoryProfiler to check if I am able to find anything but there is not much change in allocated memory,
    I'm also unloading the unused asset after each scene load.
    Anybody else faces the same issue or know anything about this issue.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    Hello,
    I'm assuming you are profiling an Android build? Because in 2018.4.30f1, Unity's Android runtime received a fix for this bug, also see this forum thread.

    I'm not yet really sure what that would mean in your case, just that the bisection to 2018.4.30f1 might mean that either it is down to the new allocation patterns resulting from that allocator change, or that the issue was there before but just became more visible this way.

    From these high level numbers, it's rather impossible to tell either way though. Did you use the Memory Profiler package? If so, the Memory Map view might be hard to read but likely the best option to figure out where the difference might come from between before and after 2018.4.30f1 as well as over time. You can open two snapshots and quickly toggle between them in by clicking on their images in the Open Snapshot section under the snapshot list. If both are set to show the Memory Map (not the Tree Map) this toggling might help spot the differences across the versions better than the Memory Map Diff view which will likely be all red because the virtual address ranges likely change too drastically between the runs.

    Also, did you check if the overall memory consumption changed, i.e. "(Total) System Used Memory" in the Memory Profiler Module between the versions? Maybe using the Android Studio profiler might also help find differences between the versions or even within the version as the reserved memory grows.
     
  3. gowthamact2022

    gowthamact2022

    Joined:
    Jun 22, 2021
    Posts:
    10
    When I test my unity game in android for some time and left it in background it says "abnormal ram usage" notification from android... What to do..
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160