www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/16/07:41:44

Date: Sun, 16 Mar 1997 15:30:15 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp AT delorie DOT com
Subject: Re: problem with malloc in djgpp?
In-Reply-To: <5gbio4$874$1@nargun.cc.uq.edu.au>
Message-ID: <Pine.SUN.3.91.970316152952.12150G-100000@is>
MIME-Version: 1.0

On 14 Mar 1997, David Wilson wrote:

> E:\DJGPP2>test 15
> Before large malloc: 9785344 phys, 31784960 virtual free
> After large malloc: 9781248 phys, 16252928 virtual free
> A 15728640-sized block uses 4096 bytes phys, 15532032 bytes virtual
> 
> E:\DJGPP2>test 16
> Before large malloc: 9781248 phys, 31784960 virtual free
> After large malloc: 9781248 phys, 16252928 virtual free
> A 16777216-sized block uses 0 bytes phys, 15532032 bytes virtual
> 
> E:\DJGPP2>test 17
> Before large malloc: 9781248 phys, 31784960 virtual free
> Malloc (17825792) failed
> 
> ------[cut here]------
> 
> This goes to prove my original point which I perhaps didn't make as clear
> as I had intended:  Free memory values under Windows aren't very
> accurate.

Sigh...  This goes to prove *my* original point that people who don't
read the FAQ are doomed to rediscover everything that's explained
there from their own bitter experience.

First, Windows won't let you allocate more than 1/2 of available
memory in one chunk.  And second, DJGPP's malloc adds a small
(8-byte?) overhead to your request, then rounds it UP to the next
integer power of 2, so 17MB actually causes `malloc' to ask for 32MB,
and you only have 31.7MB available.

- Raw text -


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