if memory leaks happens...

Started by
12 comments, last by Fish HF 19 years, 11 months ago
I used 95 for years, far far too many years. (Years after M$ discontinued support for it in fact) It was quite capable of cleaning up after leaky processes once they exited.

The main issue was that if the leaky app crashed, if often took most of the system with it!

Given how MSVC++ loves to leak, and hose my system in the process, using 95 did involve many restarts.

Finally moved to Win2k though - much, much better.

[edited by - zoggo on May 20, 2004 4:06:24 PM]
Advertisement
quote:Original post by zoggo
I used 95 for years, far far too many years. (Years after M$ discontinued support for it in fact) It was quite capable of cleaning up after leaky processes once they exited.



Win98 will clean up eventually, it is not always immediate. Try it.

for( int i = 0; i < 10000; i++)
{
char * s = malloc(1000);
}

exit(0);

and watch the resource meter in 98. In a while it will return.

Win95 was hodeous stuff, I can not beleive they actually charged people for it to be honest. Actually, I can''t believe people actually bought it. Win98 at least worked better.



I''ve definately had problems with win 98 not returning memory. Run windows explorer 10 times in a row and you''ll probably run out of memory. In theory, it should return the memory, but the 95/98/ME versions of windows are notorius for being terrible at memory management. A simple example like the malloc one just posted isn''t a good measuring stick of real life circumstances.

Even if the system does return the memory when your program exits, none of them will return it while you''re still running. So, if you have a routine that leaks memory and you keep calling it, eventually you''ll run out of memory. It''s good practice to not depend on the OS to clean up your dirty work.
quote:Original post by antareus
Hmm, my college profs always said that 9x is unable to clean up leaked memory. Anyone with Win9x want to see if that''s the case?


Depends on what kind of resource, and what kind of quit.

If you "crash" then it might not clean up memory you leaked through certain allocations.

If you shift-F5 ouf of an application in the debugger, it will NOT clean up almost ANY resources (GL contexts, etc).

If you exit the process with an ExitProcess(), most resources will get cleaned up.

I suggest wrapping your code in a __try/__except which posts a dialog box that there''s been an irrecoverable error in the program, and then call ExitProcess(). That way, you DO clean up all the memory, even when crashing.

XP (or other OS-es based on a "real kernel") don''t have this problem, and can clean up all resources as necessary when the program dies. Some subsystems may have bugs in certain versions, though.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement