Jump to content
  • Advertisement

Archived

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

Lancelet

Debug runtime question

This topic is 6339 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

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!!!

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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;}}

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!