Jump to content
  • Advertisement
Sign in to follow this  
ChaseRLewis

DX11 [DX11] Memory Management Question

This topic is 2537 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm messing around with DX11 and I'm not sure if all memory is getting deallocated properly.
I know I have called delete, delete[], ->Release(), and set all unused pointers to nullptr after calling one of the above, but still if I open and close the program a few times I notices a net loss of about 4+ MB a time. My normal memory leak checker is ViewLeaker and I'm not sure it works with COM interfaces like DirectX (it says no losses but the face my video card ran out of memory after messing around with the program for several hours the other day begs to differ).

[QUOTE/]
D3D11: WARNING: Live Device: Name="unnamed", Addr=0x028BE808, ExtRef=1 [ STATE_CREATION WARNING #2097297: LIVE_DEVICE ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x028F2A5C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Buffer: Name="unnamed", Addr=0x028F23F4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097229: LIVE_BUFFER ]
D3D11: WARNING: Live Buffer: Name="unnamed", Addr=0x028F222C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097229: LIVE_BUFFER ]
D3D11: WARNING: Live PixelShader: Name="unnamed", Addr=0x028F200C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097262: LIVE_PIXELSHADER ]
D3D11: WARNING: Live VertexShader: Name="unnamed", Addr=0x028F19DC, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097250: LIVE_VERTEXSHADER ]
D3D11: WARNING: Live InputLayout: Name="unnamed", Addr=0x028F14D4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097265: LIVE_INPUTLAYOUT ]
D3D11: WARNING: Live Buffer: Name="unnamed", Addr=0x028F1274, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097229: LIVE_BUFFER ]
D3D11: WARNING: Live DepthStencilView: Name="unnamed", Addr=0x028F10C4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097247: LIVE_DEPTHSTENCILVIEW ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x028F0EEC, ExtRef=1, IntRef=1 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live RenderTargetView: Name="unnamed", Addr=0x028F0DC4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097244: LIVE_RENDERTARGETVIEW ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x028C0854, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Query: Name="unnamed", Addr=0x028C0404, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097280: LIVE_QUERY ]
D3D11: WARNING: Live Sampler: Name="unnamed", Addr=0x028C0254, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097268: LIVE_SAMPLER ]
D3D11: WARNING: Live RasterizerState: Name="unnamed", Addr=0x028C0134, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097277: LIVE_RASTERIZERSTATE ]
D3D11: WARNING: Live DepthStencilState: Name="unnamed", Addr=0x028C003C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097274: LIVE_DEPTHSTENCILSTATE ]
D3D11: WARNING: Live BlendState: Name="unnamed", Addr=0x028C15AC, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097271: LIVE_BLENDSTATE ]
D3D11: WARNING: Live Context: Name="unnamed", Addr=0x028CE00C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT ]
D3D11: WARNING: Live Device Child Summary: Device Addr=0x028BE808
Using ID3D11Debug::ReportLiveDeviceObjects with D3D11_RLDO_DETAIL will help drill into object lifetimes. Objects with ExtRef=0 and IntRef=0 will be eventually destroyed through typical Immediate Context usage. However, if the application requires these objects to be destroyed sooner, ClearState followed by Flush on the Immediate Context will realize their destruction.
Live Context: 1
Live Buffer: 3
Live Texture1D: 0
Live Texture2D: 3
Live Texture3D: 0
Live ShaderResourceView: 0
Live RenderTargetView: 1
Live DepthStencilView: 1
Live VertexShader: 1
Live GeometryShader: 0
Live PixelShader: 1
Live InputLayout: 1
Live Sampler: 1
Live BlendState: 1
Live DepthStencilState: 1
Live RasterizerState: 1
Live Query: 1
Live Predicate: 0
Live Counter: 0
Live CommandList: 0
Live HullShader: 0
Live DomainShader: 0
Live ClassInstance: 0
Live ClassLinkage: 0
Live ComputeShader: 0
Live UnorderedAccessView: 0
[ STATE_CREATION WARNING #2097298: LIVE_OBJECT_SUMMARY ] [/QUOTE]

Share this post


Link to post
Share on other sites
Advertisement
Based on this log you leak a texture and the device. Look for “ExtRef=1“. The other objects are most likely still alive because they are attached to deice.

SmartPointer can help to reduce such problems. But as a quick check you might lock for QueryInterface calls and methods that returns texture or deice interfaces.

Share this post


Link to post
Share on other sites
Another possibility is to use PIX to identify which objects are still alive at the end of the application. This might be a little faster, and you'll get a good idea of what your app is doing (or not doing) with D3D11.

Share this post


Link to post
Share on other sites
Cleaning up leaks is good, but it's not possible for a process to leak resources after shutdown. The OS knows what handles, including all D3D handles are associated with a process, and the OS will kill those off if the process goes away.

Share this post


Link to post
Share on other sites
Was recently getting this as well. It came down to having a single resource not getting cleaned up correctly (a Constant Shader buffer).

The key thing on this, as stated before, is going through and ensuring that any item with an ExtRef > 0 should be investigated. One thing that you can do to help is add a proper name to the resource, like so:


D3D11_BUFFER_DESC constDesc;
ZeroMemory(&constDesc, sizeof(constDesc) );
constDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
constDesc.ByteWidth = sizeof( XMMATRIX );
constDesc.Usage = D3D11_USAGE_DEFAULT;

result = mD3DD3Device->CreateBuffer( &constDesc, 0, &mWVPConstBuf );

if ( FAILED(result) )
{
return S_FALSE;
}

mWVPConstBuf->SetPrivateData( WKPDID_D3DDebugObjectName, sizeof("mWVPConstBuf")-1, "mWVPConstBuf" );



Calling SetPrivateData on the D3D resource allows you to get a proper name in the debug spew. Saved me a great deal of time in trying to figure out what's what.


I'm messing around with DX11 and I'm not sure if all memory is getting deallocated properly.
I know I have called delete, delete[], ->Release(), and set all unused pointers to nullptr after calling one of the above, but still if I open and close the program a few times I notices a net loss of about 4+ MB a time. My normal memory leak checker is ViewLeaker and I'm not sure it works with COM interfaces like DirectX (it says no losses but the face my video card ran out of memory after messing around with the program for several hours the other day begs to differ).

[QUOTE/]
D3D11: WARNING: Live Device: Name="unnamed", Addr=0x028BE808, ExtRef=1 [ STATE_CREATION WARNING #2097297: LIVE_DEVICE ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x028F2A5C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Buffer: Name="unnamed", Addr=0x028F23F4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097229: LIVE_BUFFER ]
D3D11: WARNING: Live Buffer: Name="unnamed", Addr=0x028F222C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097229: LIVE_BUFFER ]
D3D11: WARNING: Live PixelShader: Name="unnamed", Addr=0x028F200C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097262: LIVE_PIXELSHADER ]
D3D11: WARNING: Live VertexShader: Name="unnamed", Addr=0x028F19DC, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097250: LIVE_VERTEXSHADER ]
D3D11: WARNING: Live InputLayout: Name="unnamed", Addr=0x028F14D4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097265: LIVE_INPUTLAYOUT ]
D3D11: WARNING: Live Buffer: Name="unnamed", Addr=0x028F1274, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097229: LIVE_BUFFER ]
D3D11: WARNING: Live DepthStencilView: Name="unnamed", Addr=0x028F10C4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097247: LIVE_DEPTHSTENCILVIEW ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x028F0EEC, ExtRef=1, IntRef=1 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live RenderTargetView: Name="unnamed", Addr=0x028F0DC4, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097244: LIVE_RENDERTARGETVIEW ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x028C0854, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Query: Name="unnamed", Addr=0x028C0404, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097280: LIVE_QUERY ]
D3D11: WARNING: Live Sampler: Name="unnamed", Addr=0x028C0254, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097268: LIVE_SAMPLER ]
D3D11: WARNING: Live RasterizerState: Name="unnamed", Addr=0x028C0134, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097277: LIVE_RASTERIZERSTATE ]
D3D11: WARNING: Live DepthStencilState: Name="unnamed", Addr=0x028C003C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097274: LIVE_DEPTHSTENCILSTATE ]
D3D11: WARNING: Live BlendState: Name="unnamed", Addr=0x028C15AC, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097271: LIVE_BLENDSTATE ]
D3D11: WARNING: Live Context: Name="unnamed", Addr=0x028CE00C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT ]
D3D11: WARNING: Live Device Child Summary: Device Addr=0x028BE808
Using ID3D11Debug::ReportLiveDeviceObjects with D3D11_RLDO_DETAIL will help drill into object lifetimes. Objects with ExtRef=0 and IntRef=0 will be eventually destroyed through typical Immediate Context usage. However, if the application requires these objects to be destroyed sooner, ClearState followed by Flush on the Immediate Context will realize their destruction.
Live Context: 1
Live Buffer: 3
Live Texture1D: 0
Live Texture2D: 3
Live Texture3D: 0
Live ShaderResourceView: 0
Live RenderTargetView: 1
Live DepthStencilView: 1
Live VertexShader: 1
Live GeometryShader: 0
Live PixelShader: 1
Live InputLayout: 1
Live Sampler: 1
Live BlendState: 1
Live DepthStencilState: 1
Live RasterizerState: 1
Live Query: 1
Live Predicate: 0
Live Counter: 0
Live CommandList: 0
Live HullShader: 0
Live DomainShader: 0
Live ClassInstance: 0
Live ClassLinkage: 0
Live ComputeShader: 0
Live UnorderedAccessView: 0
[ STATE_CREATION WARNING #2097298: LIVE_OBJECT_SUMMARY ]


[/quote]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!