Jump to content
  • Advertisement
Sign in to follow this  
Tordin

DX11 [DX11] Memory leeks that i cant get ridoff

This topic is 2535 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

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I have done that. I even only created the device and nothing more, i still get lots of Live warnings...

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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?


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

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!