malloc(3) (hopefully) set for 7.0

Poul-Henning Kamp phk at
Thu Mar 29 05:49:43 UTC 2007

In message <460AE766.6050409 at>, Jason Evans writes:

>However, there is a downside to 
>managing memory in chunks: unless we use madvise(2), every page of a 
>chunk that is touched remains physically backed until the entire chunk 
>can be unmapped.  Thus, even a single in-use page can cause retention of 
>up to 1MB of memory.  This is a bit of a catch-22, since madvise(2) is 
>too expensive to enable by default, but if we really need it, then we 
>really should be using it for all applications, since paging is a 
>system-wide issue.

The solution I have been advocating for years, is that the VM system
tell us a green/yellow/red status of memory availability, and send
a SIGVM to all processes when it gets worse.

malloc() could hook SIGVM and act intelligently based on it, and
really smart applications (a browser for instance) could hook SIGVM
and ditch the cache.

The actual flag color could be a free discovery, if we had a system-wide
mapped page in all processes.

That way, in all likelyhood, instead of starting to page out, the
processes would free enough "wasted" space, that we can avoid paging
out, at least for a fair bit longer.

Thanks for the good work on jemalloc :-)

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

More information about the freebsd-current mailing list