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

Memory Q

Started by chillah Nov 26, 2001 at 6:37 PM 10 replies 1k views
Original Post
chillah
chillah
Sorry if this has been asked before. Ok, I have a program that builds and links with no errors. I execute the program and exit it with no sign of errors. I know that my DirectInput object is not being released, but don''t know why. My question is this: Is the memory used in the DirectDraw object released after the program quits running? Thanx in advance for any help.
"I'm never alone, I'm alone all the time" - Glycerine-Bush"It starts with one thing" In The End-Linkin Park
Fruny
Fruny
Do you release them explicitly ?
If you don''t, you may be in trouble as COM objects are registered with the operating system, not with an application.

Which means that they stick around even once the application has finished.

That''s why windows memory usage creeps up with uptime. Did I mention windows''s stability ?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
chillah
chillah
I do release them with lpDI->Release(), but my code never makes it past this point.
"I'm never alone, I'm alone all the time" - Glycerine-Bush"It starts with one thing" In The End-Linkin Park
chillah
chillah
I do call that code. I added a line above and below to write to a file saying that it is being released and that it was just released. In the file it says that it is being released, but it never gets to the line saying it was just released.
"I'm never alone, I'm alone all the time" - Glycerine-Bush"It starts with one thing" In The End-Linkin Park
Oluseyi
Oluseyi
quote:
Original post by Fruny
That''s why windows memory usage creeps up with uptime. Did I mention windows''s stability ?

That seems to infer that my system''s instability is due to bad application programming? The bastards!

Whatever. chillah, do you set your pointer to NULL after releasing? Windows will clean up after your application to a certain extent, especially in debug builds, but other than tha Fruny''s comments are dead-on. Are you sure you''ve released all DirectInput devices before releasing the DI object? COM interfaces should be released in (approximately) the reverse order they are acquired.
Oluseyi
Oluseyi
quote:
Original post by chillah
I added a line above and below to write to a file saying that it is being released and that it was just released. In the file it says that it is being released, but it never gets to the line saying it was just released.

Use the debugger. It''s easier and better to trace execution of function calls this way.
chillah
chillah
I am absolutely positive that I release all of the DirectInput devices before releasing the DirectInput object. I think I will retry to make the whole thing and see if it will work.
"I'm never alone, I'm alone all the time" - Glycerine-Bush"It starts with one thing" In The End-Linkin Park
chillah
chillah
ok:

... Unacquire and release DI devices
if (lpDI)
{
ErrLog("lpDI was not NULL, releasing", __LINE__, __FILE__);
lpDI->Release();
lpDI = NULL;
ErrLog("lpDI was released", __LINE__, __FILE__); // never makes it here
}

ErrLog() is the function to write to a file so I can see what is going on

lpDI is the DI object created earlier

Edited by - chillah on November 26, 2001 8:27:07 PM

Edited by - chillah on November 26, 2001 11:44:35 PM
"I'm never alone, I'm alone all the time" - Glycerine-Bush"It starts with one thing" In The End-Linkin Park
Kaijin
Kaijin
Are you definately flushing and closing your log file before you exit the application? It might be that the DirectInput object is being released but the line is not being being writen to file. Just a thought.

- Kaijin

"If you find a job that you love you''ll never have to work again."

Topic Locked

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

Sign in to reply to this topic.