Mail Archives: djgpp/1996/08/12/04:30:13
Eli Zaretskii wrote:
>
> On 10 Aug 1996, john miller wrote:
>
> > Under DOS I believe that it is not necessary to free malloced memory
> > because DOS reclaims all of the memory when the program ends. Is the
> > same true under Windoze and Windoze 95?
>
> It is the same under any operating system. When a program exits, all its
> memory is freed by the OS.
This is not always true. If you get DosMem via Int21h/??, the function
number I forgot, the memory remains occupied. Otherwise TSRs would not
really work. If you use [mc]alloc(), you are on the safe side
and Eli is right.
But I think it is a good practice to free the memory, because the
program will hopefully crash when you have doen something
wrong in your bookkeeping. If you are really pedantic, you say
free(foo); foo=NULL;
to reliably detect dereferencing memory you have already
freed.
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* Voice/Fax Box: +49 2561 91371 2056 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -