I noticed a few weeks ago that when using OpenXR in Unity and cycling Play Mode on and off (in Editor), I get a near 500MB memory leak everytime Play Mode is stopped. This can be seen in the A-B comparison below. This happens even on a fresh project with just OpenXR added and a simple XRRig in the scene. It seems like something is preventing Unity from fully clearing the Managed Memory. I reached out to Unity but they say they haven’t been able to replicate the issue. Any ideas?
Can confirm this happens on both Vive Pro 2 and Index.
I found the bug you submitted to Unity. My team will grab it and take a look and report back.
Sounds good! I’m surprised this issue isn’t more well known. Is there any way to clear the leaked memory in the meantime? Thanks!
Hey, we investigated this and couldn’t reproduce (responded via the bug asking for more info - but I’ll post it here too):
I’ve been trying to investigate this although I haven’t yet been able to reproduce the memory leak on my side, even after trying multiple versions of Unity, OpenXR, and SteamVR. I had a few questions for you to help me try to investigate:
- How consistently do you see this memory leak? Do you see this every time you start Unity and enter/exit playmode?
- How many times approximately do you have to enter/exit playmode in order to see the 500MB memory leak?
- To confirm, are you using Unity 2022.1.14f1 and OpenXR 1.4.2? (These were the versions that the logs specified) Have you seen this for other versions?
- What OS are you using?
- What runtime are you using? (The logs indicated you’re using SteamVR) Have you noticed the memory leak for other runtimes as well?
For anyone else that finds this: we were eventually able to reproduce this and it turns out it can be reproduced without OpenXR or XR in general. We’ve passed it along to the Unity platform / scripting team to investigate.
Just fyi, doesn’t look like a fix is being worked on. Really annoying since I am getting editor crashes after entering/exiting playmode a certain amount of times. Makes iterative testing a pain…
It’s still being investigated - it was transferred to another team because we don’t think it’s being caused by OpenXR (we were able to reproduce it without XR enabled). The connection to your issue got closed for some reason. Should be open again now.