How to detect the unreleased interface?

Started by
6 comments, last by 991060 20 years ago
Hi guys,is there a general way to detect and locate unreleased interfaces in a DirectX program? I''m totally sick up of manually checking.
The sweet of life sucks.
Advertisement
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

Niko Suni

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
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]
The sweet of life sucks.
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
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]
The sweet of life sucks.
''decl'' and ''VSDecl'' are the same?

I like pie.
[sub]My spoon is too big.[/sub]
D3DDECLTYPE_D3DCOLOR

Need I say more?

-Nik

Niko Suni

This topic is closed to new replies.

Advertisement