Marc M. wrote:
> What are the requirements in terms of cleanup when terminating a plib
> application? It appears as though all of the PLIB examples just use
> 'exit(0);' and work fine. But in my program (I am using Win32 API,
> not GLUT), I get memory leaks whenever I exit the program. I've
> narrowed the cause to the calling of ssgInit();. In this function, it
> is the line 'new ssgContext' causing the leak.
Well, that is really a Windows issue, not a PLIB issue.
In all 'proper' operating systems (and I don't include the amateurish
piece of junk that Microsoft put out in that catagory), the operating
system cleans up for the application when it exits.
So, in IRIX, Solaris, BSD, Linux, MacOS (9 and X) and BeOS, programs
can allocate memory on startup - and never bother to free it. When
they exit, all trace of their existance is erased - so any files they
had open, memory they had allocated, etc is automatically recovered.
Opinions seem to vary about whether Windows actually does this reliably,
some people claim it does it correctly - but occasional reports I get
from people like you suggest that it does not. I don't run Windows,
so I have no way to test that. Perhaps some versions and some service
packs get it right whilst others do not?
Personally, if it's true - then I regard that as a bug in Windows and
not something I have to pay particular attention to.
If an operating system DOESN'T clean up after programs that have exited
then eventually you'll need to do a reboot because the accumulation of
memory 'locked away' by programs that crashed or which don't 100% clean
up before they exit will eventually force a reboot. That's an OS bug.
In contrast, all other OS's that I know of will run for years without
needing a reboot because they recover resources from programs that exited.
Clearly it's possible to write programs that recover every last itty-bitty
byte of memory that they allocated - but it's a pain in the neck to have
to go to all that trouble to work around a bug in just one OS.
Consider an occasional reboot to clear out memory part of the price you pay
for running a deeply crappy operating system!
---------------------------- Steve Baker -------------------------
HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----
|