I am developing a Qt RTC application based on owt-client-native in Windows, after I call Stream::AttachVideoRenderer() & Stream::DetachVideoRenderer several times, the memory grows rapdily.
Here is what I found the memory leak code in class WebrtcVideoRendererD3D11Impl:
d3d11_device_->GetImmediateContext(&d3d11_device_context_);
if (d3d11_device_context_ == nullptr)
return;
D3D11 debug log:
D3D11 WARNING: Live ID3D11Device at 0x00000137405D9FF0, Refcount: 13 [ STATE_CREATION WARNING #441: LIVE_DEVICE]
D3D11 WARNING: Live ID3D11Context at 0x00000137404AC920, Refcount: 155, IntRef: 1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT]
D3D11 WARNING: Live ID3DDeviceContextState at 0x00000137404EB660, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #3145742: LIVE_DEVICECONTEXTSTATE]
D3D11 WARNING: Live ID3D11BlendState at 0x00000137416396D0, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #435: LIVE_BLENDSTATE]
D3D11 WARNING: Live ID3D11DepthStencilState at 0x000001374163A170, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #436: LIVE_DEPTHSTENCILSTATE]
D3D11 WARNING: Live ID3D11RasterizerState at 0x000001373EE91900, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #437: LIVE_RASTERIZERSTATE]
D3D11 WARNING: Live ID3D11Sampler at 0x0000013741639290, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #434: LIVE_SAMPLER]
D3D11 WARNING: Live ID3D11Query at 0x00000137402B0940, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #438: LIVE_QUERY]
D3D11 WARNING: Live ID3DDeviceContextState at 0x0000013740380F90, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145742: LIVE_DEVICECONTEXTSTATE]
D3D11 WARNING: Live ID3D11RasterizerState at 0x000001374152FCD0, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #437: LIVE_RASTERIZERSTATE]
D3D11 WARNING: Live IDXGISwapChain at 0x0000013740386830, Refcount: 1 [ STATE_CREATION WARNING #442: LIVE_SWAPCHAIN]
D3D11 WARNING: Live ID3D11Texture2D at 0x00000137414AD140, Refcount: 0, IntRef: 0 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: Live ID3D11Texture2D at 0x00000137414AD590, Refcount: 0, IntRef: 0 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D]
D3D11 WARNING: Live ID3D11Fence at 0x000001374145F5E0, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #3146250: LIVE_FENCE]
D3D11 WARNING: Live ID3D11VideoProcessorEnum at 0x000001373CB70840, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145737: LIVE_VIDEOPROCESSORENUM]
D3D11 WARNING: Live ID3D11VideoProcessor at 0x0000013740953330, Refcount: 1, IntRef: 0 [ STATE_CREATION WARNING #3145738: LIVE_VIDEOPROCESSOR]
as you can see the log ID3D11Context at 0x00000137404AC920, Refcount: 155, the refcount of d3d11_device_context_ is insanely grows while decode job running.
The GetImmediateContext method increments the reference count of the immediate context by one. Therefore, you must call Release on the returned interface pointer when you are done with it to avoid a memory leak.
Possible fix solution:
add a guard statement:
if (d3d11_device_context_ == nullptr) {
d3d11_device_->GetImmediateContext(&d3d11_device_context_);
}
Hi, owt team!
I am developing a Qt RTC application based on owt-client-native in Windows, after I call
Stream::AttachVideoRenderer()
&Stream::DetachVideoRenderer
several times, the memory grows rapdily.Here is what I found the memory leak code in class
WebrtcVideoRendererD3D11Impl
:D3D11 debug log:
as you can see the log
ID3D11Context at 0x00000137404AC920, Refcount: 155
, the refcount ofd3d11_device_context_
is insanely grows while decode job running.I also found MSDN doc:
Possible fix solution:
add a guard statement: