Search code examples
c++comdirectxdirect3ddirect3d9

Direct3D9 Exception when calling Release


When I call Release() on my Direct3D9 interface, the programs stops immediately and under the debugger, I have the following output:

VERIFIER STOP 00000900: pid 0x570: A heap allocation was leaked.  

In my code, I create and free the D3D9 interface this way:

IDirect3D9 *pD3D = Direct3DCreate9( D3D_SDK_VERSION );
// Do some work...
pD3D->Release();
pD3D = nullptr;

Between the creation and release of the interface, I am able to use it normally.

This is the first time I have something like this happening and I have absolutely no clues of what is going wrong. It may be a problem with my DirectX installation but I have other software using Direct3D9 running without any problems.


Solution

  • It seems that you attched "Application Verifier" to your EXE. Appverif checks for memory leaks and it found one. If you read the full output, appverif gives you the stacktrace of the leaked allocation. You can display it by debugging your EXE with WinDbg and run the command dps STACKTRACE_ADDRES. The memory leak can come from your //do some work... code, maybe you forgot to release a referenced d3d object. It also happens that Graphical Drivers causes memory leaks detected by appverif, in this case just remove your EXE from appverif. Finaly Windbg will tell you the culprit.