Why process memory starts so high up in virtual space with FreeBSD malloc?

Giorgos Keramidas keramida at freebsd.org
Tue Dec 2 03:42:42 PST 2008


On Mon, 01 Dec 2008 14:57:23 -0800, Yuri <yuri at rawbw.com> wrote:
> Giorgos Keramidas wrote:
>> The FreeBSD malloc(3) implementation can use either mmap() or sbrk() to
>> obtain memory from the system.  It does not 'waste a high percentage of
>> memory' but it simply maps only high addresses (with an unmapped 'hole'
>> in lower addresses).
>
> But the hole it leaves with MALLOC_OPTIONS='dM' is way larger than the
> one left by 'Dm' option. Usually malloc will keep allocating addresses
> higher than this initial value and will never come back and fill some
> parts of this gap.  Therefore "wasting" this space.

The 'D' and 'M' options set what malloc() will _prefer_, they do not
force malloc() to use _only_ the particular type of memory space.  As
Dan explained in another post, both memory types will be used if there
is need for more address space.



More information about the freebsd-questions mailing list