D3D11CreateDevice 句柄泄漏

D3D11CreateDevice handle leak

提问人:Camarada 提问时间:11/17/2023 最后编辑:Camarada 更新时间:11/17/2023 访问量:17

问:

英特尔显卡驱动程序在创建 DirectX 设备时产生句柄泄漏(互斥或突变)。 设备被释放,除每次调用一个互斥锁外的所有资源。

此处描述的类似问题 https://forums.developer.nvidia.com/t/resource-leak-on-cud3d9ctxcreate-and-cuctxdestroy/8366

A 会添加可编译的代码,但 StackOverflow 规则不允许,所以只允许其中的一部分

    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;

        }
    }
Windows DirectX-11 资源泄漏

评论


答: 暂无答案