# DX11 Debug mode - Device Release is crashing

## Recommended Posts

Hi,

I have a Terrain rendering demo that is running and rendering OK, but when I run it in Debug mode (Device debug flag on and Visual studio debug build), the Device Release() method is crashing, I don't know why and I couldn't find a way to track the reason. Is there something that can tell me why the Device fail to Release?

I don't know what exactly to show you so I'll just post the App final destructor, which is trivial:

D3DApp::~D3DApp()
{
SAFE_DELETE( mBackBuffer );
ReleaseCOM( mSwapChain );
ReleaseCOM(md3dImmediateContext);

if ( mDebug )
{
mDebug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
}

ReleaseCOM(mDebug);
ReleaseCOM(md3dDevice); --> Crashing here

#if defined(DEBUG) || defined(_DEBUG)
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
_CrtDumpMemoryLeaks();
#endif
}

ReleaseCom( x ) is a simple SAFE_RELEASE kind of method, means if ( x ) { x->Release(); x = nullptr; }

SAFE_DELETE is same but deleting an object (mBackBuffer is of a wrapper TextureHandle class that wraps all my textures)

I also used our SVN server to try and track where the problem started, but it's a very slow process as running a debug session here takes ~6-7 minutes each time, and I saw it goes long back down the SVN path so not really practical to find where the problem started. However, I'm almost sure there is some better way to know why D3D isn't able to close properly.

## Create an account

Register a new account

• 18
• 18
• 11
• 21
• 16