Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
4974 Discussions

Direct3DCreate9 memory leak?

Jeff_Mcallister
Beginner
664 Views
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:
[cpp]#include 

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

	return 0;
}
[/cpp]
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.
0 Kudos
5 Replies
Peter_W_Intel
Employee
664 Views

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()?

[cpp]#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;
}

[/cpp]


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

Regards, Peter

0 Kudos
Peter_W_Intel
Employee
664 Views
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
0 Kudos
Christopher_Pisz
Beginner
664 Views
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.
0 Kudos
Peter_W_Intel
Employee
664 Views
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
0 Kudos
SergeyKostrov
Valued Contributor II
664 Views
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
0 Kudos
Reply