delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/06/15:32:52

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bug in malloc/free ?
Date: Thu, 06 Mar 1997 08:46:39 -0800
Organization: Alcyone Systems
Lines: 26
Message-ID: <331EF4EF.3788CF9D@alcyone.com>
References: <5fm6r7$6av$1 AT gjallar DOT daimi DOT aau DOT dk>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Morten Heiberg Rasmussen wrote:

> This may or may not be a bug in malloc or free. I am currently writing
> a large program that does a lot of calls to malloc and free (about
> 20.000.000 during a singe run) but it should use a more or less constant
> amount of memory at any given time.

If each allocation is requesting a roughly equal-sized block each time,
then you will speed things up a great deal by writing a suballocator --
allocate a big chunk of memory, and then partition that memory up yourself
as you need it.

> Nevertheless it runs out of memory
> at a very late stage of the execution. I can practically guarantee that
> no memory is leaking through lack of freeing.

It's possible (though I haven't checked) that memory is becoming too
fragmented from the allocations and frees, so that eventually it fails.

-- 
       Erik Max Francis, &tSftDotIotE / email:  max AT alcyone DOT com
                     Alcyone Systems /    web:  http://www.alcyone.com/max/
San Jose, California, United States /    icbm:  37 20 07 N  121 53 38 W
                                   \
              "I am become death, / destroyer of worlds."
                                 / J. Robert Oppenheimer (quoting legend)

- Raw text -


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