Skip to main content
New Participant
September 26, 2016

App eats memory when HMDUnmounted (Windows)

When my app runs and the HMD is mounted/the sensor covered memory is staying steady(over hours). When i unmount memory gets eaten away until the app crashes ~ 1GB RAM/5 minutes. Is there a memory leak? Or do i have to handle the situation in any way? My installation consists of 5 rifts dangeling from the ceiling in a museum, so there will be quite some Unmounted-Time. Is this a known limitation/bug?

Windows10/64, Runtime 1.7, Unity 5.4.1f1
This topic has been closed for replies.

22 replies

Participant
October 14, 2016
@vrdaveb We aren't using the OVROverlay, or any of the Oculus Utilities at this moment. (Since upgrading to Unity 5.4, we actually pulled out all of the OVR bits and were just using the "Oculus" in the VR selection in the Unity build settings.) Unless perhaps the OVROverlay is being used behind the scenes somewhere? The canvas we're using is a "Screen Space - Camera" canvas, but I don't think that would be using OVROverlay behind the scenes?

I was trying to see if I could re-create the issue in a fresh project, and I'm not even able to duplicate the same behavior: Removing the HMD doesn't "blackout" the screen in the fresh project like it does in my main application. It does however stop the rendering on the last frame it drew. (The OpenVR SDK allows rendering to continue while the HMD is removed, so I was at least sure that I'm using the Oculus SDK through the unity option.)

Is there something with that blackout being drawn that could be using the OVROverlay? I certainly can't seem to figure out why that's being generated in my main app, but not in the tiny fresh project I made. The fresh project certainly isn't leaking anything! Hmm.

I've asked my boss if I'm able to send you a build, but in the mean time I figured I'd see if I could provide some more information here.
Participant
October 14, 2016
Alright, I've managed to narrow it down further: I'm seeing the issue when I have a "Screen Space - Camera" canvas, that has a child with an Image.

Further, the "Run In Background" seems to be the issue yet again: Checked, removing the HMD will black the screen and the memory will leak. Unchecked, removing the HMD causes rendering to stop, but memory does not leak.

Unfortunately, running in the background is a critical feature of our application. (The Unity window on the PC will often be minimized while the Rift is in use.)

Using Unity 5.5.0b7, I've attached a project named "Empty-OculusLeak" to this post that replicates the issue. In the scene 'Main', you'll find a Camera, as well as a canvas with the UI.Image as I described above. Building and running while the HMD is unmounted, after the splash image (which I've just set to a random default image for now, because I was replicating our project as closely as possible,) memory usage should start to climb rapidly. Putting on the HMD should cause the memory usage to immediately drop.

Build again, but this time with the "Run in Background" disabled, and observe that the leak does not occur.

For now I'm writing some scripts to disable my Canvas when I'm not drawing something on it to hopefully skirt around this for the time being, but any help would be appreciated!
Inspiring
October 14, 2016
Unity 5.5 probably doesn't have the leak fix yet. Can you try 5.4.1p4 or higher?
Participant
October 14, 2016
I'm seeing the same behavior on 5.4.1p4. I've attached a new project, created with 5.4.1p4. It also has an executable build this time: Empty-OculusLeak-5.4.1p4\build\build.exe.

Perhaps it's also of note that I'm using an x64 build from the x64 editor? I'm not sure how the code paths differ per architecture, but I suppose that could be relevant?

Again, if you just run that build with the Rift unmounted memory usage should start climbing rapidly.
Inspiring
October 14, 2016
Thanks, looks like the canvas leak was never properly fixed. We're working with Unity to get a proper fix. Unfortunately, you may have to use 5.3.6p7 until we get to the bottom of it.
Participant
October 14, 2016
I've downloaded the latest tools, and written up a tiny script that checks the state of OVRManager.instance.isUserPresent, toggling my Canvas game object off when they remove the HMD, then re-enabling it when they put it back on. In my limited testing it seems to be an effective workaround for our project, but I'll keep my eyes on patch notes to see when a proper fix makes it's way down the pipeline!

Thanks for your help and quick responses, Dave!
Up and Coming
October 29, 2016
Any update on this?
Inspiring
October 29, 2016
Unity traced this back to an additional bug in Canvas management. Fixes are planned for 5.3.7p1, 5.4.2p4, and 5.5.0b11. In the meantime, you need to disable Run In Background or disable any Canvases while the app doesn't have VR focus.
New Participant
November 10, 2016
5.4.2p4 was released yesterday but it isn't 100% clear to me, from the release notes, that this issue has been fixed. Can you confirm whether this issue was in fact fixed in the 5.4.2p4 release?
Inspiring
November 15, 2016
Yes, the leak should be fully fixed in 5.4.2p4. Also, it should have been fixed in 5.3.7p1 and 5.5.0b11.