From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,c617820a3952d228 X-Google-Attributes: gidfee84,public X-Google-Thread: 1014db,c617820a3952d228 X-Google-Attributes: gid1014db,public From: Mark Brown Subject: Re: Why does my C Realloc() fail? Date: 1998/04/11 Message-ID: #1/1 X-Deja-AN: 343281336 References: <352d36a9.0@calwebnnrp> Followup-To: comp.lang.c Organization: The Tardis Project X-WWW-Homepage: http://www.tardis.ed.ac.uk/~broonie/ Newsgroups: comp.lang.c,comp.unix.osf.osf1 biju@web1.calweb.com (Biju Srinivasan) writes: > 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? It needn't. realloc() may simply work by getting the amount of memory you requested and copying the data from the pointer you passed (there's not even any requirement that it free the existing memory, although there are very valid quality of implementation issues with an implementation that doesn't). To understand why the implementation would do this, consider the case where thee is a block of memory allocated immediately after the one being realloc()ed. How could one both increase the size of the first block and keep pointers to the second block valid? You are almost certainly going to need to try to process the data in smaller sections - 100MB of memory is an awful lot of memory to be using. [followups to comp.lang.c - I've no idea about how OSF/1 handles this] -- Mark Brown mailto:broonie@tardis.ed.ac.uk (Trying to avoid grumpiness) http://www.tardis.ed.ac.uk/~broonie/ EUFS http://www.ed.ac.uk/~filmsoc/