D3D11CreateDevice handle leak

52 Views Asked by At

Intel Graphics Driver produce handle leak (Mutex or Mutant) when create DirectX device. Device is released, all resources except one mutex per call.

Similar problem described here https://forums.developer.nvidia.com/t/resource-leak-on-cud3d9ctxcreate-and-cuctxdestroy/8366

A would add compilable code but StackOverflow rules don't allow, so only part of it

    auto pid = GetCurrentProcess();

    for (int c = 0; c < 500; c++)
    {

        ComPtr<IDXGIAdapter1> handle1;
        ComPtr<IDXGIAdapter2> handle2;
        for (UINT i = 0; factory->EnumAdapters1(i, &handle1) != DXGI_ERROR_NOT_FOUND; ++i) {
            DXGI_ADAPTER_DESC2 description{};
            if (FAILED(handle1.As(&handle2)) || FAILED(handle2->GetDesc2(&description)) || (description.Flags & DXGI_ADAPTER_FLAG_SOFTWARE))
                continue;

            ComPtr<ID3D11Device> device;
            //Handles count here increases on each iteration
            hr = procD3D11CreateDevice(handle2.Get(), D3D_DRIVER_TYPE_UNKNOWN, 0,
                D3D11_CREATE_DEVICE_VIDEO_SUPPORT | D3D11_CREATE_DEVICE_DEBUG, LEVELS, ARRAYSIZE(LEVELS), D3D11_SDK_VERSION, &device, 0, 0);
            if (FAILED(hr))
                return 3;

        }
    }
0

There are 0 best solutions below