Skip to main content
GameDev.net gamedev.net
🔒 Locked

Release Problem

Started by sansured Oct 16, 2005 at 6:07 PM 1 replies 1.4k views
Original Post
sansured
sansured
I have some problems about releasing my IDirect3DDevice9* pd3dDevice struct. In common files in DXut.cpp has a code like that for releasing structure.

if( pd3dDevice->Release() > 0 )  
{
DXUTDisplayErrorMessage( DXUTERR_NONZEROREFCOUNT );
DXUT_ERR( L"DXUTCleanup3DEnvironment", DXUTERR_NONZEROREFCOUNT );
}

In the beggining everything was ok but when i tried to open some mesh's.When i try to quit program this Error Message coming. Error Message

// Changing this
pd3dDevice->Release() > 0

// to this
pd3dDevice->Release() > 56
// Working

Why i can't release the the structure? How can i fix the problem? Thanks.
Agony
Agony
The value returned by Release() is the number of references that still exist to the object that just got released. It is usually not recommended that you pay too much attention to this value, unless you know specifics about what references it has. See, reference counting is a way of making sure that an object doesn't get deleted from memory as long as certain bits of code still need it. When you call Release(), it is merely saying that you (or this specific part of code) don't need it anymore. Other parts of code might still need access to it. This is not unexpected.

In short, I doubt anything is wrong with your code.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
skybreaker
skybreaker
you should release every directx COM interface by youerself before release the pd3ddevice.the return value is the num of interface you haven't released yet.If you don't do so you will meet a "memery leak" and finally program will break down with an "out of memery" error,this maybe keep on until you restart your computer .

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.