Update from Unity2019LTS to Unity2021LTS greatly increased memory consumption

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).

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

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.

142.2 MB
InitializeGfxDevice UnityPlayer.dll!metro
21.5 MB
InitializeIL2cpp->UnityPlayer.dll
51.4 MB
StartXRSubsystems lead to allocation within WinXRRuntime.dll
34.0 MB
d3d12.CreateCommoandQueue  WindowsMirage.dll -> d3d12core.dll
0.5MB
CreatePlatformThread UnityPlayer.dll
13.3 MB
CreateDxResources -> d3d11.dll
2.5 MB
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.

3 Likes