What are the advantages and disadvantages if we always use mmap to allocate memory instead of malloc ?

Florian Weimer fw@deneb.enyo.de
Wed Aug 12 07:58:10 GMT 2020


* 孙世龙 sunshilong via Libc-help:

> What are the advantages and disadvantages if we always use mmap to
> allocate memory instead of malloc.

On Linux, the advantage of using mmap is that the kernel might find
usable address space in more cases.  There is also no problem when
multiple allocators each call mmap indepedently.  With sbrk, that
would be a problem.  As long as address space is available, sbrk
maintains a single memory mapping, which can be more efficient.


More information about the Libc-help mailing list