lkml.org 
[lkml]   [1997]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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

\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.047 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site