Archived

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

How to detect the unreleased interface?

This topic is 5009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There''s not a general way other than the standard Release() method of the IUnknown interface to lower the DX objects'' reference count.

For each interface query (be it CreateDevice, for example, or IUnknown->QueryInterface and the derived methods) you need exactly 1 Release() call. Now, if your program is well structured, it''s not really difficult to follow this pattern.

Kind rgds,
Nik

Share this post


Link to post
Share on other sites
I don''t think there is any way to locate the specific interface that wasn''t released but DirectX can output a load of leak information at application shut down if you increase the debug output level, so at least you know you''ve got leaks, it''s then just a question of finding them

-Mezz

Share this post


Link to post
Share on other sites
Thanks Mezz and Nik02, actually I was doing what Mezz suggested before writing this post, but I still got a leak without any clue where it happened. I've checked the code for 3 times, all interfaces I created seem to be properly released, the leak is still there. It's just a small program though, only 7 interfaces and I just couldn't find the bug!!!

[edited by - 991060 on March 26, 2004 11:39:05 AM]

Share this post


Link to post
Share on other sites
Perhaps, if you want to, post some of the code and we could help track it down.
Other than that I don''t really know what to suggest.
Perhaps there is a DX interface queried from another DX interface that hasn''t been release, an example is calling something like IDirect3DDevice9::GetTexture() and not releasing it when done.

-Mezz

Share this post


Link to post
Share on other sites
HahaC the bug is finally found, I used a CDXUTDirectionWidget object but forgot to delete it. Now there's another problem, I have this D3D error in the output window: "Vertex shader function usage (D3DDECLUSAGE_COLOR,0) does not have corresponding usage in the current vertex declaration"
here's the code:

D3DVERTEXELEMENT9 decl[] =
{

{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
{0, 24, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
D3DDECL_END()
};
.
.
.
V_RETURN( pd3dDevice->CreateVertexDeclaration(decl, &VSDecl) );
V_RETURN( pd3dDevice->SetVertexDeclaration( VSDecl ));



I think I've already set the VS decl properly, haven't I?




[edited by - 991060 on March 26, 2004 12:48:12 PM]

Share this post


Link to post
Share on other sites