Search Unity

Question Update from Unity2019LTS to Unity2021LTS greatly increased memory consumption

Discussion in 'AR' started by EdgarRodrigoSantos, Sep 20, 2022.

  1. EdgarRodrigoSantos

    EdgarRodrigoSantos

    Joined:
    Dec 15, 2020
    Posts:
    8
    Hello,

    We recently upgraded our project (Hololens 2) from Unity2019LTS (that used the Legacy XR system) to Unity 2021.3.10f1 (using the new XR plugin system and all recomended setting by MRKT2).

    We noticed a big increase in memory consumption (~500Mb) at startup. The same Hololens2 app that used to take ~400Mb was now using ~900Mb at startup, which was pretty concerning.

    For context, one of the causes was that MRTK2 using OpenXR was including other platform's controllers (material, textures, 3d models) in the Default Hololens2 Profile, as well as other unecessary things (for us). After we prunned things to target just Hololens2, it saved us >200Mb.
    Using the memory profiler, we now see just a slightly bigger "used memory" (~50MB) which we are ok with.

    The main problem we have is that, in total, we are still seeing a >300MB difference in used memory to which the main contributer is "Untracked Memory". In the following screenshot we captured a side-by-side comparison in the memory profiler between Unity 2019/LegacyXR (left) and Unity2021 (right).

    upload_2022-9-20_12-26-53.png

    As you can see, "untracked memory" almost doubled with the update (225.7mb to 443mb).
    Is this normal? The difference is pretty significant and we are wondering why this happens.

    Thank you
     

    Attached Files:

  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Hey, sorry for delayed response here - we investigated this with Windows Performance Analyzer and were able to get a breakdown of memory that falls under the Untracked memory section.

    Code (CSharp):
    1. 142.2 MB
    2. InitializeGfxDevice UnityPlayer.dll!metro
    3. 21.5 MB
    4. InitializeIL2cpp->UnityPlayer.dll
    5. 51.4 MB
    6. StartXRSubsystems lead to allocation within WinXRRuntime.dll
    7. 34.0 MB
    8. d3d12.CreateCommoandQueue  WindowsMirage.dll -> d3d12core.dll
    9. 0.5MB
    10. CreatePlatformThread UnityPlayer.dll
    11. 13.3 MB
    12. CreateDxResources -> d3d11.dll
    13. 2.5 MB
    14. CreateTexture2DWorker WinXRRuntime.dll
    The above accounted for ~265MB of untracked memory.

    Microsoft has confirmed 90-100mb of that memory is due to an architectural shift with their OpenXR runtime vs their old APIs. Unfortunately it's unlikely to be fixed. But - they did remove the extra controller models and textures for HL2 from MRTK - this fix was released in MRTK 2.8.3.

    There's still ~160mb unaccounted for that we need to investigate, specifically in the first two sections above. We'll let you know if we find any details there, but just wanted to provide an update for anyone that hits this.