Typical implementations of malloc
use brk
/sbrk
as the primary means of claiming memory from the OS. However, they also use mmap
The obvious advantage is that you can grow the last allocation in place, which is something you can't do with mmap(2)
(mremap(2)
is a Linux extension, not portable).
For naive (and not-so-naive) programs which are using realloc(3)
eg. to append to a string, this translates in a 1 or 2 orders of magnitude speed boost ;-)