Sign in to follow this  
Burnhard

Memory Leek

Recommended Posts

Burnhard    96
Ok, so I thought I'd be all smarty pants and use CComPtr to hold my D3D objects. It turns out though, that I have memory leaks from doing so. I'm only holding the following (I'm just starting the framework): // D3D Interfaces CComPtr<IDirect3D9> MyD3D9; CComPtr<IDirect3DDevice9> MyDevice; Nothing else. That is, I'm creating an IDirect3D9 and an IDirect3DDevice9 and that's all. I've allocated nout else. I can see the destructor on the class that owns the CComPtr getting called on program shut-down. I know I'm not doing anything daft like getting references to the interfaces twice (the method that does this has a guard on it to ensure that is not allowed). Yet D3D debugger output says the following (below). Anyone have an explanation? Direct3D9: :====> ENTER: DLLMAIN(00a6e6e0): Process Detach 00001198, tid=000016a8 Direct3D9: (INFO) :MemFini! Direct3D9: (WARN) :Memory still allocated! Alloc count = 7 Direct3D9: (WARN) :Current Process (pid) = 00001198 Direct3D9: (WARN) :Memory Address: 00377000 lAllocID=1 dwSize=000047f8, (pid=00001198) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 00A6E4CB Direct3D9: (ERROR) : [1] : Address 00A6E59B Direct3D9: (ERROR) : [2] : Address 00A6E440 Direct3D9: (ERROR) : [3] : Address 00A62DB4 Direct3D9: (ERROR) : [4] : Address 4FDFAF2E Direct3D9: (ERROR) : [5] : Address 00415200 Direct3D9: (ERROR) : [6] : Address 00411F77 Direct3D9: (ERROR) : [7] : Address 00411BFF Direct3D9: (ERROR) : [8] : Address 00417579 Direct3D9: (ERROR) : [9] : Address 004172DD Direct3D9: (ERROR) : [10] : Address 7C817077 Direct3D9: (ERROR) : [11] : Address 00000000 Direct3D9: (ERROR) : [12] : Address 00000000 Direct3D9: (ERROR) : [13] : Address 00000000 Direct3D9: (ERROR) : [14] : Address 00000000 Direct3D9: (ERROR) : [15] : Address 00000000 Direct3D9: (WARN) :Memory Address: 0037df58 lAllocID=20 dwSize=000017a0, (pid=00001198) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 00A650D4 Direct3D9: (ERROR) : [1] : Address 00A65EBF Direct3D9: (ERROR) : [2] : Address 00A665F8 Direct3D9: (ERROR) : [3] : Address 00A62DD5 Direct3D9: (ERROR) : [4] : Address 4FDFAF2E Direct3D9: (ERROR) : [5] : Address 00415200 Direct3D9: (ERROR) : [6] : Address 00411F77 Direct3D9: (ERROR) : [7] : Address 00411BFF Direct3D9: (ERROR) : [8] : Address 00417579 Direct3D9: (ERROR) : [9] : Address 004172DD Direct3D9: (ERROR) : [10] : Address 7C817077 Direct3D9: (ERROR) : [11] : Address 00000000 Direct3D9: (ERROR) : [12] : Address 00000000 Direct3D9: (ERROR) : [13] : Address 00000000 Direct3D9: (ERROR) : [14] : Address 00000000 Direct3D9: (ERROR) : [15] : Address 00000000 Direct3D9: (WARN) :Memory Address: 0037d720 lAllocID=21 dwSize=00000018, (pid=00001198) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 00A651C2 Direct3D9: (ERROR) : [1] : Address 00A65EBF Direct3D9: (ERROR) : [2] : Address 00A665F8 Direct3D9: (ERROR) : [3] : Address 00A62DD5 Direct3D9: (ERROR) : [4] : Address 4FDFAF2E Direct3D9: (ERROR) : [5] : Address 00415200 Direct3D9: (ERROR) : [6] : Address 00411F77 Direct3D9: (ERROR) : [7] : Address 00411BFF Direct3D9: (ERROR) : [8] : Address 00417579 Direct3D9: (ERROR) : [9] : Address 004172DD Direct3D9: (ERROR) : [10] : Address 7C817077 Direct3D9: (ERROR) : [11] : Address 00000000 Direct3D9: (ERROR) : [12] : Address 00000000 Direct3D9: (ERROR) : [13] : Address 00000000 Direct3D9: (ERROR) : [14] : Address 00000000 Direct3D9: (ERROR) : [15] : Address 00000000 Direct3D9: (WARN) :Memory Address: 0037f768 lAllocID=22 dwSize=00000160, (pid=00001198) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 00A6679F Direct3D9: (ERROR) : [1] : Address 00A62DD5 Direct3D9: (ERROR) : [2] : Address 4FDFAF2E Direct3D9: (ERROR) : [3] : Address 00415200 Direct3D9: (ERROR) : [4] : Address 00411F77 Direct3D9: (ERROR) : [5] : Address 00411BFF Direct3D9: (ERROR) : [6] : Address 00417579 Direct3D9: (ERROR) : [7] : Address 004172DD Direct3D9: (ERROR) : [8] : Address 7C817077 Direct3D9: (ERROR) : [9] : Address 00000000 Direct3D9: (ERROR) : [10] : Address 00000000 Direct3D9: (ERROR) : [11] : Address 00000000 Direct3D9: (ERROR) : [12] : Address 00000000 Direct3D9: (ERROR) : [13] : Address 00000000 Direct3D9: (ERROR) : [14] : Address 00000000 Direct3D9: (ERROR) : [15] : Address 00000000 Direct3D9: (WARN) :Memory Address: 0037d7a8 lAllocID=23 dwSize=00000044, (pid=00001198) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 00A6E4CB Direct3D9: (ERROR) : [1] : Address 00A6E59B Direct3D9: (ERROR) : [2] : Address 00A6E440 Direct3D9: (ERROR) : [3] : Address 00ADD2D5 Direct3D9: (ERROR) : [4] : Address 00ADB696 Direct3D9: (ERROR) : [5] : Address 00A62E2E Direct3D9: (ERROR) : [6] : Address 4FDFAF2E Direct3D9: (ERROR) : [7] : Address 00415200 Direct3D9: (ERROR) : [8] : Address 00411F77 Direct3D9: (ERROR) : [9] : Address 00411BFF Direct3D9: (ERROR) : [10] : Address 00417579 Direct3D9: (ERROR) : [11] : Address 004172DD Direct3D9: (ERROR) : [12] : Address 7C817077 Direct3D9: (ERROR) : [13] : Address 00000000 Direct3D9: (ERROR) : [14] : Address 00000000 Direct3D9: (ERROR) : [15] : Address 00000000 Direct3D9: (WARN) :Memory Address: 011132e8 lAllocID=122 dwSize=00000420, (pid=00001198) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 00A6E4CB Direct3D9: (ERROR) : [1] : Address 00A6E59B Direct3D9: (ERROR) : [2] : Address 00A6E440 Direct3D9: (ERROR) : [3] : Address 00ADE3A2 Direct3D9: (ERROR) : [4] : Address 00ADEED6 Direct3D9: (ERROR) : [5] : Address 00ADEDF2 Direct3D9: (ERROR) : [6] : Address 00ADE1C6 Direct3D9: (ERROR) : [7] : Address 004153EA Direct3D9: (ERROR) : [8] : Address 00411F77 Direct3D9: (ERROR) : [9] : Address 00411BFF Direct3D9: (ERROR) : [10] : Address 00417579 Direct3D9: (ERROR) : [11] : Address 004172DD Direct3D9: (ERROR) : [12] : Address 7C817077 Direct3D9: (ERROR) : [13] : Address 00000000 Direct3D9: (ERROR) : [14] : Address 00000000 Direct3D9: (ERROR) : [15] : Address 00000000 Direct3D9: (WARN) :Memory Address: 01113778 lAllocID=123 dwSize=00000420, (pid=00001198) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 00A6E4CB Direct3D9: (ERROR) : [1] : Address 00A6E59B Direct3D9: (ERROR) : [2] : Address 00A6E440 Direct3D9: (ERROR) : [3] : Address 00ADE3C0 Direct3D9: (ERROR) : [4] : Address 00ADEED6 Direct3D9: (ERROR) : [5] : Address 00ADEDF2 Direct3D9: (ERROR) : [6] : Address 00ADE1C6 Direct3D9: (ERROR) : [7] : Address 004153EA Direct3D9: (ERROR) : [8] : Address 00411F77 Direct3D9: (ERROR) : [9] : Address 00411BFF Direct3D9: (ERROR) : [10] : Address 00417579 Direct3D9: (ERROR) : [11] : Address 004172DD Direct3D9: (ERROR) : [12] : Address 7C817077 Direct3D9: (ERROR) : [13] : Address 00000000 Direct3D9: (ERROR) : [14] : Address 00000000 Direct3D9: (ERROR) : [15] : Address 00000000 Direct3D9: (WARN) :Total Memory Unfreed From Current Process = 27028 bytes Direct3D9: :====> EXIT: DLLMAIN(00a6e6e0): Process Detach 00001198

Share this post


Link to post
Share on other sites
MJP    19754
There's a very common mistake that people make with CComPtr and Direct3DCreate9, and I suspect you're making the same one. Are you doing something like this?

CComPtr<IDirect3D9> MyD3D9;
MyD3D9 = Direct3DCreate9(D3D_SDK_VERSION);

Share this post


Link to post
Share on other sites
Burnhard    96
Ok, I've got to use attach, apparently, otherwise the interface is leaked. The answer was all made clear here:

http://legalizeadulthood.wordpress.com/2009/01/11/direct3d-programming-tip-3-use-smart-pointers/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this