www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/12/05/16:45:59

Date: Tue, 05 Dec 2000 23:42:43 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: "Greg Holdridge" <greg AT holdridge7 DOT freeserve DOT co DOT uk>
Message-Id: <7458-Tue05Dec2000234242+0200-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
CC: djgpp AT delorie DOT com
In-reply-to: <90j6oj$fjt$1@news5.svr.pol.co.uk>
(greg AT holdridge7 DOT freeserve DOT co DOT uk)
Subject: Re: realloc causing fault
References: <90j6oj$fjt$1 AT news5 DOT svr DOT pol DOT co DOT uk>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Greg Holdridge" <greg AT holdridge7 DOT freeserve DOT co DOT uk>
> Newsgroups: comp.os.msdos.djgpp
> Date: Tue, 5 Dec 2000 17:02:33 -0000
> 
> Ok so the problem seems to be in the realloc since the last thing in the log
> file is always 'attempt realloc.'  Examining the log file, it shows that the
> base address of the memory block slowly moves upwards through memory as its
> size increases up to about 150K of data having been allocated at which point
> the program performs its dramatic exit.
> 
> Clearly the program cannot have run out of memory at this small size

Your calculations are mistaken.  You don't take into account the
overhead of each allocation (8 bytes per allocated buffer).  So in
fact you allocate much more than 150KB.  You also do it very
inefficiently: allocating memopry 1 byte at a time, then reallocating
it for the next byte is about the worst memory usage I could think of.

I could try guessing where your program crashes and why, but I don't
want to guess.  Please post the full crash message printed by the
program, after running symify on it, and please show on the source
what line crashes.  Sections 9.3 and 12.2 of the DJGPP FAQ list should
help you.

> and it
> doesnt explain why the base address of the memory block is moving (it surely
> cant have to move the block every single time.)

If you want to understand that, read the source of malloc and realloc
in djlsr203.zip.  There is a good reason for the address to move up.

- Raw text -


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