delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/13/07:43:27

Date: Sun, 13 Jun 1999 11:42:31 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Grzegorz Jablonski <gwj AT dmcs DOT p DOT lodz DOT pl>
cc: djgpp AT delorie DOT com
Subject: Re: Exec does not free all memory
In-Reply-To: <7jth75$fqf$1@kujawiak.man.lodz.pl>
Message-ID: <Pine.SUN.3.91.990613114153.17906c-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sat, 12 Jun 1999, Grzegorz Jablonski wrote:

> When the program below (run as parent.exe 0) is run, it eventually allocates
> all the dos memory and quits. Similar program compiled with Borland C 3.1
> works correctly. I suspect that the problem is probably with the transfer
> buffer, which is not freed after exec.

It is actually much worse: _none_ of the memory, DOS or otherwise, is
freed when you call one of the functions of the `execXX' family.  The
problem is that DOS doesn't have the `exec' system call that
overwrites the program with another image, so `execXX' are actually
`spawnXX' in disguise: they call `spawn', and then exit to DOS.

Obviously, the transfer buffer and other memory cannot be freed on
`exec' because the parent program still runs; in particular, the
transfer buffer is used to pass the long command line to the child
program.  If you know how to avoid these problems when calling
programs, please suggest a solution.

> The problem occured, when I tried to
> upgrade the program version from within the program itself.

I don't see how this could cause any practical problems: the
conventional memory usage by each subsidiary program is about 18KB, so
you need much more than a single `exec' to eat up all the conventional
memory, unless you have 20KB to begin with.

- Raw text -


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