Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    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 2019.4.40 Reserved managed heap of the Android emulator x86 architecture game suddenly increased

Discussion in 'Editor & General Support' started by rayriver, Oct 8, 2023.

  1. rayriver

    rayriver

    Joined:
    Dec 14, 2015
    Posts:
    1
    Hi, everyone,

    I encountered a problem when my project was running on the Android emulator. The game was based on x86 architecture, while the game is running, the project's reserved managed heap memory suddenly increased from 300MB to 1300MB (approximate value, it may be 300MB or 400MB, both have increased by about 1000MB).

    I tried to simulate this problem by allocating memory manually, as shown in the figure below. There are no other memory allocations at this time.



    The code to simulate manual allocation is roughly as follows (the method will be called once when I click a button):

    Code (CSharp):
    1. public static void AllocManagedMemory(float mb)
    2. {
    3.     var bytes = new byte[(int)(mb * 1024 * 1024)];
    4.     _allocManagedMemoryList.Add(bytes);
    5. }
    6.        
    7. private static List<byte[]> _allocManagedMemoryList = new List<byte[]>();
    Since our project runs on the x86 architecture in the Android emulator, this sudden increase of 1G reserved heap memory will easily make the game reach the 4G virtual memory limit.

    I read this article and it mentioned that on most platforms the reserved managed heap expansion will be double. But from what I have observed, in most cases the reserved managed heap grows by tens of MB instead of twice. And I don’t understand why this sudden increase of 1G (4 times) occurs.

    https://docs.unity3d.com/2019.3/Doc...acticeUnderstandingPerformanceInUnity4-1.html
    I also tested the arm64 architecture and the above situation did not occur. However, since the x86 architecture runs much faster during simulation than arm64, we need to use the x86 architecture.

    I would like to ask, is this sudden increase of 1G reserved heap memory normal? How can it be avoided?

    Thank you.
     

    Attached Files:

    • 35.gif
      35.gif
      File size:
      324.4 KB
      Views:
      99