Direct3DCreate9 memory leak?

Direct3DCreate9 memory leak?

Inspector's "Detect Memory Problems" and "Locate Memory Problems" lists multiple memory leaks, kernel resource leaks, etc. related to DirectX. The following code should reproduce what I'm seeing:

#include 

int main()
{
	IDirect3D9 *pD3D = Direct3DCreate9(D3D_SDK_VERSION);     
	pD3D->Release();    

	return 0;
}

If the create/release are placed in a loop, Process Explorer shows that memory and handle use increases for the first iterations, but the increase slows quickly -- once a peak is reached there are no further increases. Is this behavior due to Inspector's interactions with resource caching within DirectX? DirectX does not report any memory leaks, and otherwise appears to be functioning correctly in its original context. What is causing Inspector to report these issues? Thanks for your help.

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I can reproduce this problem after installing the Microsoft DirectX SDK (June 2010) - then built a simple test case, ran Inspector XE 2011 Update 5 (build 180252), it detected "Kernel resource leak", actually it waswrong report since we have "pD3D->Release();"
Is it possible that Inspector hasn't detected (tracked) resource release in pD3D->Release()?

#include "stdafx.h"
#include 
#include 
#include   

void loop_foo()
{
 for (int i=0; i<3; i++)
 {
  IDirect3D9 *pD3D = Direct3DCreate9(D3D_SDK_VERSION);        
  pD3D->Release();       
 }
}
int _tmain(int argc, _TCHAR* argv[])
{
 //IDirect3D9 *pD3D = Direct3DCreate9(D3D_SDK_VERSION);        
 //pD3D->Release();       
 loop_foo();
    return 0;
}

I will report this to dev team, and post again if there is progressor solution.

Regards, Peter

The reported resource leaks are suppressed since it's DirectX3D internal and irrelevant to user's app.

This is not a bug in product, and just add MC suppression to ignore (not report) them.

Regards, Peter

You are creating a COM interface. I was under the impression that leaks within COM objects were not detected. Am I incorrect? If so, I'd really love to profile some of the COM objects in my solution.

It looks like the bug in DirectX3d for allocating COM objectand release it quickly, repeat it at next iteration in a loop. Some kernel resource still was notreleasedbut the user apply it again...

If yoursolutiondoesn't work in this way, you don't care of this issue; If you allocate/releasesame COM objects frequently (e.g. inloop), use Suppression for "kernel resource" in order not to report them - but memory check still can work smoothly.

Regards, Peter

Quoting Peter Wang (Intel)It looks like the bug in DirectX3d for allocating COM object...
It is hard to believe that Microsoft has a problem here because that method is a fundamental one.

Best regards,
Sergey

Leave a Comment

Please sign in to add a comment. Not a member? Join today