Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

D3D11 objects leak in the the MediaSDK samples

Igall_N_
Beginner
1,024 Views

Hello,

 

I am testing the decode_sample and I noticed that the sample leaks D3D11 object. if enabling debug on D3D11 Device by using the D3D11_CREATE_DEVICE_DEBUG flag, on application exit the refCount on few objects is not 0:

D3D11 WARNING: Live Producer at 0x00F201B4, Refcount: 1850. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F47058, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F29FF8, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F16B4C, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F2FF74, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F78184, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F78454, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F78C6C, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F807BC, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F812F4, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F81E2C, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F82964, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F8349C, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F83FD4, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F84B0C, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F859FC, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F860E4, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00F867CC, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00FBFB10, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00FC3B6C, Refcount: 924. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x00FC4644, Refcount: 924. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x0785811C, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x078582EC, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x07859C34, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x07859E04, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x07828204, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x078283D4, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x08176924, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x08177AFC, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x08177FDC, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x0817875C, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]

 

if you use the ID3D11Debug and call ReportLiveDeviceObjects, you can get more details:

 

D3D11 WARNING: Live ID3D11Device at 0x00F2013C, Refcount: 1851 [ STATE_CREATION WARNING #441: LIVE_DEVICE]
D3D11 WARNING: 	Live ID3D11Context at 0x00F47058, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT]
D3D11 WARNING: 	Live ID3DDeviceContextState at 0x00F29FF8, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #3145742: LIVE_DEVICECONTEXTSTATE]
D3D11 WARNING: 	Live ID3D11BlendState at 0x00F16B4C, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #435: LIVE_BLENDSTATE]
D3D11 WARNING: 	Live ID3D11DepthStencilState at 0x00F2FF74, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #436: LIVE_DEPTHSTENCILSTATE]
D3D11 WARNING: 	Live ID3D11RasterizerState at 0x00F78184, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #437: LIVE_RASTERIZERSTATE]
D3D11 WARNING: 	Live ID3D11Sampler at 0x00F78454, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #434: LIVE_SAMPLER]
D3D11 WARNING: 	Live ID3D11Query at 0x00F78C6C, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #438: LIVE_QUERY]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F807BC, Refcount: 0, IntRef: 2 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F812F4, Refcount: 0, IntRef: 146 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F81E2C, Refcount: 0, IntRef: 152 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F82964, Refcount: 0, IntRef: 153 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F8349C, Refcount: 0, IntRef: 51 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F83FD4, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F84B0C, Refcount: 0, IntRef: 145 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F859FC, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F860E4, Refcount: 0, IntRef: 133 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00F867CC, Refcount: 0, IntRef: 140 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live IDXGISwapChain at 0x00FBFB10, Refcount: 1 [ STATE_CREATION WARNING #442: LIVE_SWAPCHAIN]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00FC3B6C, Refcount: 924, IntRef: 924 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11Texture2D at 0x00FC4644, Refcount: 924, IntRef: 924 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: 	Live ID3D11VideoProcessorOutputView at 0x0785811C, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145741: LIVE_PROCESSOROUTPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorInputView at 0x078582EC, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145740: LIVE_PROCESSORINPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorOutputView at 0x07859C34, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145741: LIVE_PROCESSOROUTPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorInputView at 0x07859E04, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145740: LIVE_PROCESSORINPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorOutputView at 0x07828204, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145741: LIVE_PROCESSOROUTPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorInputView at 0x078283D4, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145740: LIVE_PROCESSORINPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorOutputView at 0x08176924, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145741: LIVE_PROCESSOROUTPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorInputView at 0x08177AFC, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145740: LIVE_PROCESSORINPUTVIEW]
D3D11 WARNING: 	Live ID3D11VideoProcessorOutputView at 0x08177FDC, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145741: LIVE_PROCESSOROUTPUTVIEW]

please note that before calling "ReportLiveDeviceObjects" I've set all CComPtr/CComQIPtr class memebers to nullptr.

here is the system analyzer:

Intel(R) Media Server Studio 2016 R2 - System Analyzer (32-bit)


The following versions of Media SDK API are supported by platform/driver
[opportunistic detection of MSDK API > 1.19]:

        Version Target  Supported       Dec     Enc
        1.0     HW      Yes             X       X
        1.0     SW      Yes             X       X
        1.1     HW      Yes             X       X
        1.1     SW      Yes             X       X
        1.2     HW      Yes             X       X
        1.2     SW      Yes             X       X
        1.3     HW      Yes             X       X
        1.3     SW      Yes             X       X
        1.4     HW      Yes             X       X
        1.4     SW      Yes             X       X
        1.5     HW      Yes             X       X
        1.5     SW      Yes             X       X
        1.6     HW      Yes             X       X
        1.6     SW      Yes             X       X
        1.7     HW      Yes             X       X
        1.7     SW      Yes             X       X
        1.8     HW      Yes             X       X
        1.8     SW      Yes             X       X
        1.9     HW      Yes             X       X
        1.9     SW      Yes             X       X
        1.10    HW      Yes             X       X
        1.10    SW      Yes             X       X
        1.11    HW      Yes             X       X
        1.11    SW      Yes             X       X
        1.12    HW      Yes             X       X
        1.12    SW      Yes             X       X
        1.13    HW      Yes             X       X
        1.13    SW      Yes             X       X
        1.14    HW      Yes             X       X
        1.14    SW      Yes             X       X
        1.15    HW      Yes             X       X
        1.15    SW      Yes             X       X
        1.16    HW      Yes             X       X
        1.16    SW      Yes             X       X
        1.17    HW      Yes             X       X
        1.17    SW      Yes             X       X
        1.18    HW      Yes             X       X
        1.18    SW      Yes             X       X
        1.19    HW      Yes             X       X
        1.19    SW      Yes             X       X

Graphics Devices:
        Name                                         Version             State
        NVIDIA GeForce 940MX                         10.18.13.6871       Active
        Intel(R) HD Graphics 530                     20.19.15.4483       Active

System info:
        CPU:    Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
        OS:     Microsoft Windows 10 Enterprise
        Arch:   64-bit

Installed Media SDK packages (be patient...processing takes some time):
        Intel(R) Media SDK 2016 R2

Installed Media SDK DirectShow filters:

Installed Intel Media Foundation Transforms:
        Intel(R) Hardware M-JPEG Decoder MFT : {00C69F81-0524-48C0-A353-4DD9D54F9A6E}
        Intel(R) Hardware VP8 Sync Decoder MFT : {451E3CB7-2622-4BA5-8E1D-44B3C41D0924}
        Intel(R) Hardware VP8 Decoder MFT : {6D856398-834E-4A89-8EE5-071BB3F58BE4}
        Intel(R) Quick Sync Video H.264 Encoder MFT : {4BE8D3C0-0515-4A37-AD55-E4BAE19AF471}
        Intel(R) Hardware H265 Encoder MFT : {BC10864D-2B34-408F-912A-102B1B867B6C}

 

 

0 Kudos
1 Reply
Igall_N_
Beginner
1,024 Views

I found the leak in the sample_common project used in decode_sample and other projects as well.

 

in D3D11_device.cpp, RenderFrame method, there are 6 CComPtr class membersthat are passed to D3D11 functions with the row pointer, so the old object in the CComPtr is not cleared, the objects are:

 

m_pDXGIBackBuffer

m_pOutputView

m_pInputViewLeft

m_pTempTexture

m_pInputViewLeft

m_pInputViewRight

so the fix is to set those to nullptr before changing the row pointer.

I also suggest to add this in the distructor of the class:

m_pD3D11Ctx->ClearState();

m_pD3D11Ctx->Flush();

 

 

0 Kudos
Reply