4 ms·
mmap is more general than memory mapping files. It "establish[es] a mapping between an address space of a process and a memory object". In particular, many allo
by correct_horse 6y ago
mmap is more general than memory mapping files. It "establish[es] a mapping between an address space of a process and a memory object". In particular, many allocators (malloc and friends) use mmap to get a block of memory from the OS with mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS, -1, 0); or similar.
- mhh__ 6y agoDo any allocators use anything else these days? D's std.experimental.allocator module is helpful for building allocators bit by bit even for eventual use in C++ or C.
- JoshTriplett 6y ago> Do any allocators use anything else these days? Yes, some allocators still support using sbrk, though that's a bad idea for security reasons (ASLR).
- jashmatthews 6y agoIIUC, glibc malloc still manages one arena with sbrk and then grabs other arenas via mmap.