On 3/14/07, Tulip Rasputin <[EMAIL PROTECTED]> wrote:
> When my task is shutting down wont the OS (linux or solaris) anyways free all 
> the memory associated with that task? If thats the case then i dont need to 
> explicitly free the memory as the OS would do it for me. Is this correct?

Yes, the OS most likely will take care of cleaning up after you --
freeing memory, closing files, etc... BUT it's very bad design and
programming practice to rely on this!!!!!!!!!!!!!!!!!

If the process becomes zombified, for instance, those resources will
be unrecoverable until you can destroy the process (if you can). And
this kind of crash can just be a symptom of deeper problems in the
software taht are causing memory leaks.

It just makes sense to have your program be safe and well-behaved.
There are plenty of tools out there (valgrind, for instance) to help
you track down memory leaks. You may even consider using C++ (if you
aren't already) and use well-behaved and tested container classes. T
Hruska's "Safe C++" book is also a good place to look at for handling
and designing software to address these kinds of problems, I believe
it's linked from the files page and is free to use for members of this
list).

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi

Reply via email to