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

Unreleased resources in imgui_impl_dx11.cpp #1944

Closed
cbrl opened this issue Jul 13, 2018 · 1 comment
Closed

Unreleased resources in imgui_impl_dx11.cpp #1944

cbrl opened this issue Jul 13, 2018 · 1 comment
Labels

Comments

@cbrl
Copy link

cbrl commented Jul 13, 2018

Version/Branch of Dear ImGui:

1.62

Back-end file/Renderer/OS:

imgui_impl_dx11.cpp / DirectX 11 / Windows

My Issue/Question:

The function ImGui_ImplDX11_Init() calls QueryInterface() several times, which increases the refcount of the interface it returns. However, Release() is never called on these interfaces. Relevant code below.

bool    ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
{
    // Get factory from device
    IDXGIDevice* pDXGIDevice = NULL;
    IDXGIAdapter* pDXGIAdapter = NULL;
    IDXGIFactory1* pFactory = NULL;
    if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) != S_OK)
        return false;
    if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) != S_OK)
        return false;
    if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) != S_OK)
        return false;

    g_pd3dDevice = device;
    g_pd3dDeviceContext = device_context;
    g_pFactory = pFactory;

    return true;
}

pDXGIDevice and pDXGIAdapter should be released before the function exits. g_pFactory also needs be released during shutdown.

@ocornut
Copy link
Owner

ocornut commented Jul 13, 2018

Hello @Vatora. This looks right, I have pushed a change to fix it for both DX10 and DX11 back-end (tested by enabling the D3D11_CREATE_DEVICE_DEBUG flag). Thank you for reporting this!

@ocornut ocornut closed this as completed Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants