Xref: utzoo comp.lang.c:40221 comp.os.msdos.programmer:5720 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!percy!m2xenix!quagga!ucthpx!uctcs.uucp!gram From: gram@uctcs.uucp (Graham Wheeler) Newsgroups: comp.lang.c,comp.os.msdos.programmer Subject: Does TC's farrealloc have a bug? Message-ID: <1991Jun19.083945.8921@ucthpx.uct.ac.za> Date: 19 Jun 91 08:39:45 GMT Sender: news@ucthpx.uct.ac.za (UCT News Admin.) Reply-To: gram@uctcs.uucp (Graham Wheeler) Organization: Dept. of Computer Science, University of Cape Town Lines: 29 I am reposting this article as I never saw the original appear when using nn and have had no responses, so I assume that it got lost. I have an application in which I am allocating a number of variable sized records, of average size about 6 bytes. Whenever the size changes, I use farrealloc. I have over 300kb available at the time I start allocating these nodes. I also keep track of the number of allocated bytes. My problem is that I get a memory allocation failure at about 120kb of allocated memory. This must mean one of two things: i) either there is a bug in TC (actually TC++ v1.0) so that when realloc fails to resize a block and allocates a new one it doesn't free the old one; or ii) the allocated blocks are being held on a linked list with an overhead of (I would guess) 12 bytes per block (two far pointers and one long size). This would mean that my nodes are actually using up 3 times more memory than I am actually using for record storage. Personally, I think it is better to have the free blocks on a linked list as you get the maximum use from your memory that way. I don't know how TC does it. Does anyone know which of these two theories is correct? Or is there a different explanation? Graham Wheeler | "That which is weak conquers the strong, Data Network Architectures Lab | that which is soft conquers the hard. Dept. of Computer Science | All men know this; none practise it" University of Cape Town | Lao Tzu - Tao Te Ching Ch.78