Memory Allocation

Doug Gwyn gwyn at smoke.BRL.MIL
Thu May 4 23:36:46 AEST 1989


In article <461 at chem.ucsd.EDU> tps at chem.ucsd.edu (Tom Stockfisch) writes:
>You waste up to a factor of 4 with a power-of-2 implementation,
>not including fragmentation.

The hypothetical application gloms onto a sufficiently large chunk of
memory and doles it out itself, using whatever suballocation scheme
seems appropriate for the application.  If you mean that
	void *my_heap = malloc( 1024 * 1024 * 16 );
may over-extend the program data break by up to 16Mbytes due to using
a "buddy system" scheme, I see a factor of two (not four) here, but the
problem lies with whoever provided an allocator with such horrible
properties in the C library.  In such a case, if one knows that sbrk()
is available, it should probably be used here instead of malloc().



More information about the Comp.lang.c mailing list