Mail Archives: djgpp/1996/10/22/15:48:25
In article <845921032 DOT 28340 DOT 0 AT abwillms DOT demon DOT co DOT uk>, "Alaric B.
Williams" <alaric AT abwillms DOT demon DOT co DOT uk> writes
>How serious is that power-of-two waste - in that is it then free for
>the next allocation to be taken from (ie if I then request 32-18 =
>14Mb will it not 'allocate' any more), or is it really that bad?
In one sense it really is wasted, the block is allocated and you won't
suddenly find it reused. However virtual memory paging will almost
certainly scavenge the unused pages if required, though frankly I prefer
to avoid the wastage in the first place.
>
>If so, what's the point? Surely it's no slower to allocate to the
>nearest word?
The binary bin algorithm used is *incredibly* fast at allocating memory,
and on machines with properly implemented virtual memory not necessarily
wasteful. It also avoid memory fragmentation. Allocating to the nearest
word is harder to manage. It is of course possible to substitute your
own malloc routine ;)
--
Paul Shirley
- Raw text -