www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/05/17/09:57:40

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Message-ID: <3CE4B60B.E68E28AB@yahoo.com>
Date: Fri, 17 May 2002 03:49:31 -0400
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: Malloc/free DJGPP code
References: <10205161914 DOT AA17309 AT clio DOT rice DOT edu> <3CE41EB8 DOT 619484D9 AT yahoo DOT com> <9743-Fri17May2002100518+0300-eliz AT is DOT elta DOT co DOT il>
Reply-To: djgpp-workers AT delorie DOT com

Eli Zaretskii wrote:
> 
> > Date: Thu, 16 May 2002 17:03:52 -0400
> > From: CBFalconer <cbfalconer AT yahoo DOT com>
> > >
> > > It might be possible to make sbrk() return these blocks to DPMI, but
> > > I have no plans to revisit that ugly assembler code unless something's
> > > badly broken.
> >
> > It should be totally unnecessary, because the malloc code is the
> > only access to sbrk provided in the whole system (barring emacs).
> 
> Emacs is not the only program that uses sbrk directly.
> 
> Also, don't forget that there are other programs running on the same
> box, at least if you run on Windows.  So returning unused memory to
> the OS would be a Good Thing.

The problem is that you can't return a complete block to the
system, because the internal allocation mechanism requires that
something always be left over.  Once the unexpected sbrk is
received the old block becomes completely available, and gets
used.  Forcing saving of a final piece would also be wasteful.

What you can do is reduce a sbrk block.  But once the system
returns a noncontiguous chunk, which it is most likely to do if
there are other processes, all earlier chunks are locked up. 
Changing that would require a lot more code and processing, and
the number of chunks is open-ended, meaning more memory use to
keep track.
-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


- Raw text -


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