TITLE: Unix malloc behaviour PROBLEM: odkahn@eos.ncsu.edu (OpherD. Kahn), 14 Jul 92 I am allocating the following structure/class that has a sizeof == 80. it seems that it takes ~127 bytes, but that seems like too much. RESPONSE: sjm@bcrki65.bnr.ca (Stuart MacMartin), 14 Jul 92 This is the standard performance vs. space tradeoff. Most UNIX boxes use a "power of 2" malloc scheme: To allocate n bytes, add 4 (or 8 on some platforms), and find the next highest power of 2 to get the number of bytes actually allocated. There is an adjustment to this at 1/2 K to 2K where allocating a power of 2 bytes will actually give you that many bytes. e.g. allocating 4 Mb will not give you 8Mb but allocating 4Mb+256 bytes will give you 8Mb. Such algorithms are vastly faster than some previous algorithms. For example, some of our applications took hours to initialize when we first ported to one platform because that platform's malloc did not use such a scheme. However, there are times when this extra space results in excessive paging. If you are allocating and deallocating tens of thousands of small structures, it might be better to write your own memory manager for those structures. For most allocations, you are probably better off using malloc, though, for C code. I don't know about new.