News for hackers. Stuff that matters.
Re:Writing a Memory Allocator (2019) by andi999 on Sunday December 13, 2020 @02:29AM (#25404958)
Can you explain what you mean by mmap is how memory is obtained nowadays?
Re:Writing a Memory Allocator (2019) by yaantc on Sunday December 13, 2020 @03:54AM (#25405219)
mmap is not only to map a file content into a process address space, it can also be used to request memory from the OS using the MAP_ANONYMOUS flag. Early on a malloc-like allocator would use brk/sbrk to get a chunk of "raw" memory, and manage this for the user providing access using malloc/free. Nowadays the same "raw" memory can be obtained using an anonymous map. A raw pool, when unused, can be returned to the OS by unmapping it.

Using an anonymous map provides address space randomization by default (for the raw pool location), whereas brk/sbrk extends a limit and because of this are predictable.

Re:Writing a Memory Allocator (2019) by DmitrySoshnikov on Sunday December 13, 2020 @04:04PM (#25410266)
sbrk is emulated via mmap today on MacOS and others, this is an abstraction (for bump allocation), not just a function

you may implement custom sbrk via mmap easily

Re:Writing a Memory Allocator (2019) by mhh__ on Sunday December 13, 2020 @04:23AM (#25405332)
sbrk isn't even supported on some platforms anymore, if I'm not mistaken