delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/06/09/20:47:54

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <9606100030.AA12024@clio.rice.edu>
Subject: Re: Strange malloc()/free() behaviour
To: k3040e4 AT c210 DOT edvz DOT uni-linz DOT ac DOT at (Oberhumer Markus)
Date: Sun, 9 Jun 1996 19:30:18 -0600 (CDT)
Cc: djgpp-workers AT delorie DOT com
In-Reply-To: <199606092343.BAA21128@c210.edvz.uni-linz.ac.at> from "Oberhumer Markus" at Jun 10, 96 01:43:02 am

> It looks more like a bug to me. I malloc all available memory,
> free everything and then malloc() won't work any more.

This isn't "normal" behavior.  If you try to allocate the memory in the
same size blocks as you originally used, it's still available.  The 
problem is the current algorithm is tuned ONLY for speed.  It rounds
each allocation up to a factor of two, then gets the new area from a
list of blocks in that size.  There are relatively few lists since the
number of sizes typically encountered is small.

I personally don't need speed as much as memory efficiency (you can search
a lot of lists for the cost of a single page fault).  The default malloc
is FREE, which means you can build commercial apps with it, unlike some
other LGPLed sources.  

I suggest you search for and try another malloc package, or write one you
like better and contribute it as free (non LGPLed).

- Raw text -


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