From: cgreen@yosemite.atc.com (Christopher Green)
Subject: Re: Why does my C Realloc() fail?
Date: 1998/04/10 [thread overview]
Message-ID: <6gln7k$8a3@newshub.atmnet.net> (raw)
In-Reply-To: 352d36a9.0@calwebnnrp
In article <352d36a9.0@calwebnnrp>,
Biju Srinivasan <biju@web1.calweb.com> wrote:
>Platform = DEC Alpha (OSF1 V4.0)
>Why does my C realloc() fail?
>A single malloc works for as big as 134 MBytes.
>Realloc fails for a size of 101 MBytes following an alloc of 100 MBytes.
>Doesn't realloc claim the space assigned to the original pointer and add
>extra space to it?
[snip]
Typically, realloc() allocates a new block of the requested size, copies
the old block to it, then frees the old block and returns the new block.
The situation where there is a large free block immediately following
the old block is rare; some realloc()'s may be able to take advantage
of it, but you can't count on it.
In this case, the problem may be that you have exceeded the per-process
heap size limit or the paging (swap) file size when realloc() tried to
allocate the new block, and that is why realloc() failed. You can raise
the per-process limit with ulimit up to some system-specified maximum;
you have to get your sysadmin to raise the maximum to go beyond that.
Digital UNIX (which still calls itself OSF1 when you invoke uname) has
two different swap behaviors. The default behavior is conservative:
anytime you allocate memory, there must be free space in the swap file
for it. The alternative is optimistic behavior: the system will allo-
cate memory freely, but will fail if it has to be swapped and the swap
file is already full. See the man page for swapon for details.
--
Chris Green Email cgreen@atc.com
Advanced Technology Center Phone (714) 583-9119
22982 Mill Creek Drive ext. 220
Laguna Hills, CA 92653 Fax (714) 583-9213
next prev parent reply other threads:[~1998-04-10 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-09 4:00 Why does my C Realloc() fail? Biju Srinivasan
1998-04-09 4:00 ` Dann Corbit
1998-04-10 4:00 ` Christopher Green [this message]
1998-04-10 4:00 ` Exil Q Trob
1998-04-11 4:00 ` Mark Brown
1998-04-22 4:00 ` Jeff Donsbach
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox