Skip to main content
gamedev.net
🔒 Locked

Debug runtime question

Started by Lancelet Jan 12, 2001 at 9:28 PM 2 replies 600+ views
Original Post
Lancelet
Lancelet
Hi everyone, I have a question: Is it necessary to do anything other than call the Release() function to free up an IDirectDraw7 interface? The problem is the following: When I run the DirectX 8 debug APIs, with hardware mode disabled, I always get messages (in the Visual Studio output window, of course) about having memory still allocated when the program finishes. To isolate the problem, I wrote a simple problem that calls DirectDrawCreateEx(), and then _immediately_ releases the IDirectDraw7 object with a Release() call. With full debugging messages turned on, I get the expected responses about the driver starting up, etc..., then about it shutting down, and finally a line saying that the driver is FREE. Then the program exits, and in the output window there''s always a set of error message saying that there is memory still allocated. I''m trying to write a well-behaved application, and this is _really_ holding me up. Interestingly enough, however, when I turn ON hardware support, I don''t get the same memory error message from DirectX. It''s as though the hardware version thinks I''m doing everything correctly, but the software version doesn''t. What am I doing wrong? Is this a DirectX bug? Does anyone know if there''s a place on the Microsoft site where they post reported bugs? Can somebody check to see if they get the same problems? Any other ideas?!!??!!! Please help!!!
Tornado
Tornado
This is how I usually release an interface:

  
LPDIRECTDRAW7 g_pDDraw=NULL;

// Create the interface here and everything


if (g_pDDraw != NULL)
{
g_pDDraw->Release();
g_pDDraw = NULL; // To make sure we don''t try to release this interface twice

}




- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
Quantum
Quantum
Yeah you should check if it''s not NULL before you release it.

To make it easier you can do it with a macro:

#define SafeRelease(x) {if(x){ x->Release(); x=NULL;}}
Lancelet
Lancelet
Yep, I''ve been doing that. I also normally check the return values, etc..., and that''s not the problem. I just cut that stuff out to make things as simple as possible in the program I''ve been using to duplicate the error. Thanks for pointing it out, though - I guess I should have said that. :-)

Just to clarify, the DirectDrawCreateEx() function succeeds, and the debugging messages seem to indicate that the Release() function also succeeds (and the pointer is not NULL before I call Release() on it, etc...). The problem is that even after I''ve released the interface, and the debug messages say that the driver is "FREE", I _still_ get memory error messages. I''m not requesting pointer to any other interfaces: just getting a pointer to an IDirectDraw7 interface, and then immediately releasing it.

Any ideas?

Topic Locked

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

Sign in to reply to this topic.