[DX11] Memory leeks that i cant get ridoff

Started by
7 comments, last by bubu LV 12 years, 8 months ago
Hello!

I noticed that i got memory leaks from the dx debug device.
i have been on this for ever trying to solve it but how hard i try i still get the same ones...

Example :

D3D11: WARNING: Live Device: Name="unnamed", Addr=0x00286EE8, ExtRef=1 [ STATE_CREATION WARNING #2097297: LIVE_DEVICE ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x00288E4C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Query: Name="unnamed", Addr=0x002889EC, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097280: LIVE_QUERY ]
D3D11: WARNING: Live Sampler: Name="unnamed", Addr=0x002887B4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097268: LIVE_SAMPLER ]
D3D11: WARNING: Live RasterizerState: Name="unnamed", Addr=0x0028858C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097277: LIVE_RASTERIZERSTATE ]
D3D11: WARNING: Live DepthStencilState: Name="unnamed", Addr=0x00288404, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097274: LIVE_DEPTHSTENCILSTATE ]
D3D11: WARNING: Live BlendState: Name="unnamed", Addr=0x0028CDA4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097271: LIVE_BLENDSTATE ]
D3D11: WARNING: Live Context: Name="unnamed", Addr=0x0228006C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT ]
D3D11: WARNING: Live Device Child Summary: Device Addr=0x00286EE8

When i google the warnings i only get post about ppl who havent released it right, but i are more than sure that i have!

Any clues Internet?
"There will be major features. none to be thought of yet"
Advertisement

Hello!

I noticed that i got memory leaks from the dx debug device.
i have been on this for ever trying to solve it but how hard i try i still get the same ones...

Example :

D3D11: WARNING: Live Device: Name="unnamed", Addr=0x00286EE8, ExtRef=1 [ STATE_CREATION WARNING #2097297: LIVE_DEVICE ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x00288E4C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Query: Name="unnamed", Addr=0x002889EC, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097280: LIVE_QUERY ]
D3D11: WARNING: Live Sampler: Name="unnamed", Addr=0x002887B4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097268: LIVE_SAMPLER ]
D3D11: WARNING: Live RasterizerState: Name="unnamed", Addr=0x0028858C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097277: LIVE_RASTERIZERSTATE ]
D3D11: WARNING: Live DepthStencilState: Name="unnamed", Addr=0x00288404, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097274: LIVE_DEPTHSTENCILSTATE ]
D3D11: WARNING: Live BlendState: Name="unnamed", Addr=0x0028CDA4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097271: LIVE_BLENDSTATE ]
D3D11: WARNING: Live Context: Name="unnamed", Addr=0x0228006C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT ]
D3D11: WARNING: Live Device Child Summary: Device Addr=0x00286EE8

When i google the warnings i only get post about ppl who havent released it right, but i are more than sure that i have!

Any clues Internet?


Trust me, you haven't. I'm currently working on a planet renderer and everytime I get memory leaks, I find that I, indeed had some obscure situation where they weren't released. Try slowly commenting out code sections until you get a clean exit.
Currently trying to make a planet renderer. After many hours of work, somehow I know It'll never be complete.
Also, If I help you, please give me an ++
I have done that. I even only created the device and nothing more, i still get lots of Live warnings...
"There will be major features. none to be thought of yet"
The list shows that you have an outstanding device reference. What happens if you do a double release on your device before exiting the program? You can also check the status of the objects with PIX to see if there is something that you hadn't considered before...
Try setting debug names for all the Direct3D objects you create - that includes device, textures, buffers, states, etc... Then this debug display will include name of object that is alive (instead of name="unamed"). For textures, for example, use name of file you load. For buffers use name of mesh/model you are storing there, and so on.

Do it like this: http://msdn.microsoft.com/en-us/library/ff476881.aspx

Then you will exactly which objects are alive.

The list shows that you have an outstanding device reference. What happens if you do a double release on your device before exiting the program? You can also check the status of the objects with PIX to see if there is something that you hadn't considered before...



Nice, that got rid of everything for me!

How come i have to do it twice?


"There will be major features. none to be thought of yet"
Are you calling on some object like buffer, or shader GetDevice method? GetDevice method increments reference count by one, so you should also add Release call after you process device returned by GetDevice method.
As MartinsM says everytime you use GetDevice or GetBuffer it actually increments a reference counter.

This means if you don't release after you've done these functions it'll warn that some objects and anything linked to it are still active.

Calling release at these points decreases the ref counter and the object is still alive.

For example

ID3D11Texture2D* pBackBuffer = nullptr;
if(FAILED(swapChain_->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( void** )&pBackBuffer ))) //increments ref counter
{
MessageBox( NULL, "Failed to get the back buffer.", "Error", MB_OK );
return false;
}

if(FAILED(device_->CreateRenderTargetView( pBackBuffer, NULL, renderTarget)))
{
MessageBox( NULL, "Failed to create a render target from the back buffer.", "Error creating render target", MB_OK );
return false;
}
pBackBuffer->Release(); // called release to decrease ref counter


Aside from this its mostly a case of looking for sampler/blender/rasterizer states that haven't been released.
And if you are not comfortable with calling manually Release, then simply use CComPtr (from atlbase.h) everywhere instead of raw ID3D11xyz pointers:
{
CComPtr<ID3D11Texture2D> pBackBuffer;
if(FAILED(swapChain_->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( void** )&pBackBuffer ))) //increments ref counter
{
MessageBox( NULL, "Failed to get the back buffer.", "Error", MB_OK );
return false;
}

if(FAILED(device_->CreateRenderTargetView( pBackBuffer, NULL, renderTarget)))
{
MessageBox( NULL, "Failed to create a render target from the back buffer.", "Error creating render target", MB_OK );
return false;
}
} // no need to call pBackBuffer->Release(), it will be called automatically

This topic is closed to new replies.

Advertisement