Messages in this thread |  | | Date | Tue, 28 Jan 1997 17:45:34 -0500 (EST) | From | David Schwartz <> | Subject | Re: Memory allocation errors |
| |
On Tue, 28 Jan 1997, Alan Cox wrote:
> You can use mmap() to get a block of memory you can hand back if you wish
Yep. And you can easily write malloc/free implementations that operate on multiple 'pools' with differing lifetimes. Each 'pool' can be 'mmap'ed and the whole thing either freed when the pool's lifetime expires or when the last allocation from that pool is freed.
If your malloc/free pattern has special characteristics, don't use the generic malloc/free routines -- use your own that take advantage of those characteristics. Slab allocators for large numbers of identically sized objects, pool allocators for variable sized (or single objects) with a known lifetime, and so on.
Programs that expect or require any special behavior from malloc/free like this are broken, IMO. You can force them to work by using an LD_PRELOAD to give them a malloc/free implementation that uses mmap/munmap for allocations above a certain size.
David Schwartz
|  |