Archived

This topic is now archived and is closed to further replies.

spillsome

Is Directx buggy ?

Recommended Posts

I overloaded the new operator to try find memory leaks in my DX program. It founds a lot of memory leaks hat don''t come from my code. Is directX so buggy or do I miss something ? example of output : Detected memory leaks! Dumping objects -> {312} normal block at 0x00CABAD0, 64 bytes long. Data: < > 00 00 00 00 01 00 00 00 CD CD CD CD CD CD CD CD {311} normal block at 0x00CABA50, 64 bytes long. Data: < > 03 00 00 00 02 00 00 00 00 00 00 00 CD CD CD CD {310} normal block at 0x00CAB9D0, 64 bytes long. Data: < > 01 00 00 00 02 00 00 00 01 00 00 00 01 00 00 00 {309} normal block at 0x00CAB950, 64 bytes long. Data: < > 00 00 00 00 01 00 00 00 04 00 00 00 09 00 00 00 {308} normal block at 0x00CAB8D0, 64 bytes long. Data:

50 00 00 00 49 00 00 00 4D 00 00 00 4B 00 00 00 {307} normal block at 0x00CAB880, 20 bytes long. Data: < > 00 00 00 00 D0 BA CA 00 04 00 00 00 02 00 00 00 {306} normal block at 0x00CAB830, 20 bytes long. Data: < P > 00 00 00 00 50 BA CA 00 04 00 00 00 03 00 00 00 {305} normal block at 0x00CAB7E0, 20 bytes long. Data: < > 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 {304} normal block at 0x00CAB790, 20 bytes long. Data: < > 00 00 00 00 D0 B9 CA 00 04 00 00 00 04 00 00 00 {303} normal block at 0x00CAB740, 20 bytes long. Data: < P > 00 00 00 00 50 B9 CA 00 04 00 00 00 04 00 00 00 { {313} normal block at 0x00CABB50, 64 bytes long. Data: < J > B0 4A CA 00 CD CD CD CD CD CD CD CD CD CD CD CD {45} normal block at 0x00CA4AB0, 1112 bytes long. Data: < G200D.dll > 00 00 00 00 47 32 30 30 44 2E 64 6C 6C 00 00 00

Share this post


Link to post
Share on other sites
Yup, agree with JoeyBlow2 here.

DirectX uses its own allocators for internal object management so your overloaded new & delete won''t affect them.

What you''re seeing is DirectX''s debug allocator telling you about some unreleased objects.

With COM objects, that can happen when there''s still a reference count being held for an object. A common thing that catches people is Get* calls and some Set* calls taking references (so that the parent object doesn''t get destroyed while your code still has a reference to it).

For debugging purposes you can see the current reference count by checking the return value of Release()


If you look at the DirectX control panel applet you can also get some DirectX objects to create a breakpoint on objects that are leaking (i.e. you pass in the AllocId listed in the debug output and it breaks next time you touch that object).

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
Have you set

pDev->SetTexture(0,NULL);
pDev->SetIndices(...NULL);
pDev->SetStreamSource(0,NULL);


If not, they're still in memory. Although you Release() them at the end.

This 3 calls add 1 to the reference counter of the Interfaces. So you have to NULL them at the end. (like above)


-------------------------
Kongo
http://www.8ung.at/kongo/index.html
e-mail: kongo@gmx.at

[edited by - Kongo on September 3, 2003 4:14:57 PM]

Share this post


Link to post
Share on other sites
If you''re lazy like me, you can just use D3DSpy, it tells you the return value of Release(). Good for those who don''t like too much work (breakpoints.. so hard to press F9)

Share this post


Link to post
Share on other sites
quote:
DirectX uses its own allocators for internal object management so your overloaded new & delete won''t affect them.

Yet D3DX uses the overloaded ones, yes?
As far as I recall D3DX needs standards-compliant new and delete operators, right? (return a unique pointer with 0 sized allocations, or something similar?)

quote:
Original post by Kongo
Have you set

pDev->SetTexture(0,NULL);
pDev->SetIndices(...NULL);
pDev->SetStreamSource(0,NULL);


If not, they''re still in memory. Although you Release() them at the end.

This 3 calls add 1 to the reference counter of the Interfaces. So you have to NULL them at the end. (like above)

There''s been a discussion before about whether these increment the reference count or not (they don''t increment the reference count of the interface, but maybe they increment the reference count of the object internally).

Anyway, whatever they do, you don''t need to do the calls above, because the device will do them when being released.

Share this post


Link to post
Share on other sites
quote:
Original post by Coder
quote:
DirectX uses its own allocators for internal object management so your overloaded new & delete won''t affect them.

Yet D3DX uses the overloaded ones, yes?
As far as I recall D3DX needs standards-compliant new and delete operators, right? (return a unique pointer with 0 sized allocations, or something similar?)


Yes. I forgot about that.

Since D3DX is linked in as a lib rather than being a precompiled/standalone DLL it can be affected by other libs and overloaded functions you have in your app.

Share this post


Link to post
Share on other sites