2017-05-24 46 views
0

我试图追查“内存泄漏”。然而这似乎并不像一个真正的内存泄漏,因为调用ReportLiveDeviceObjects报道,有0引用DirectX11 COM对象0引用未发布

D3D11 WARNING: Live ID3D11Texture2D at 0x00000140D3FE44F0, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D] 
D3D11 WARNING: Live ID3D11RenderTargetView at 0x00000140D3FCBB60, Refcount: 0, IntRef: 0 [ STATE_CREATION WARNING #428: LIVE_RENDERTARGETVIEW] 
D3D11 WARNING: Live ID3D11Texture2D at 0x00000140D3FE5BF0, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #425: LIVE_TEXTURE2D] 
D3D11 WARNING: Live ID3D11RenderTargetView at 0x00000140B8EDB000, Refcount: 0, IntRef: 0 [ STATE_CREATION WARNING #428: LIVE_RENDERTARGETVIEW] 

正如你所看到的,ID3D11RenderTargetView对象既有0内部和外部参考。但它仍然是一个活的对象。什么可能导致这种情况发生?

为了清楚起见,我用这通过SharpDX,虽然这应该不会影响从11 DirectX的输出

调试

通讯问题: https://github.com/sharpdx/SharpDX/issues/903

回答

2

DirectX 11的使用资源的“递延毁灭”,所以通常如果你需要强制销毁你需要Flush。例如,在Direct3D game templates,你需要完全取消绑定并摧毁调整前的渲染目标:

// Remove any bound render target or depth/stencil buffer 
ID3D11RenderTargetView* nullViews [] = { nullptr }; 
m_d3dContext->OMSetRenderTargets(_countof(nullViews), nullViews, nullptr); 

// Destroy the views (which themselves hold the references to the resources) 
m_renderTargetView.Reset(); 
m_depthStencilView.Reset(); 

// Flush the immediate context to force cleanup 
m_d3dContext->Flush(); 
+0

这正是问题。我正在调用flush,但是在我放置渲染目标之前而不是之后。 – Axiverse