Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in VR_InitInternal2 #1221

Closed
risa2000 opened this issue Oct 22, 2019 · 2 comments
Closed

Memory leak in VR_InitInternal2 #1221

risa2000 opened this issue Oct 22, 2019 · 2 comments

Comments

@risa2000
Copy link

@mann1x here (cmbruns/pyopenvr#71) pointed out that he observed a memory leak when repeatedly calling OpenVR init function.

I was able to reproduce it in the native code:

#include <iostream>

#define OPENVR_BUILD_STATIC
#include <openvr/openvr.h>

//  Initialize OpenVR subsystem and return IVRSystem interace.
vr::IVRSystem* init_vrsys(vr::EVRApplicationType app_type)
{
    vr::EVRInitError eError = vr::VRInitError_None;
    vr::IVRSystem* vrsys = vr::VR_Init(&eError, app_type);

    if (eError != vr::VRInitError_None) {
        std::cerr << vr::VR_GetVRInitErrorAsEnglishDescription(eError) << '\n';
        return nullptr;
    }
    return vrsys;
}

int main(int argc, char* argv[])
{

    while(true) {
        // Initializing OpenVR runtime (IVRSystem)
        auto vrsys = init_vrsys(vr::VRApplication_Background);
        if (nullptr != vrsys) {
            break;
        }
    }

    vr::VR_Shutdown();
    return 0;
}

When running this code without starting SteamVR, the VR_Init call fails with an error Not starting vrserver for background app (121). Each failure seem to leak ~ 100KB on the stack in function VR_InitInternal2 as illustrated on the picture below.

openvr_init_mem_leak

This apparently becomes a problem when someone repeatedly calls VR_Init in an attempt to detect whether SteamVR has started.

The issue is observed on the stable 1.7.15 and the latest beta as well.

@kisak-valve
Copy link
Member

Hello @risa2000, this issue is already being tracked at #195. Closing as a duplicate.

@risa2000
Copy link
Author

@kisak-valve Thanks for letting me know, it is funny how the reports look similar even though I was not aware of the former.
Anyway, do you plan to fix? Why has it been open for so long?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants