www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/12/04:30:13

Xref: news2.mv.net comp.os.msdos.djgpp:7094
From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Freeing and not freeing Windoze memory
Date: Mon, 12 Aug 1996 09:10:23 +0100
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 38
Message-ID: <320EE6EF.41C6@LSTM.Ruhr-UNI-Bochum.De>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 960811111912 DOT 24678T-100000 AT is>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019