Date: Sun, 16 Mar 1997 15:30:15 +0300 (IDT) From: Eli Zaretskii 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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.