3 ms·
It might be worth pointing out that the OpenBSD developers replaced their malloc(3) implementation with one based on mmap(2) ... quite a while ago. IIRC, it at
by krylon 9y ago
It might be worth pointing out that the OpenBSD developers replaced their malloc(3) implementation with one based on mmap(2) ... quite a while ago.
IIRC, it attempts to use end-of-page allocation by default for blocks of a certain size. It is also possible to enable guard pages on a per process basis or globally.
Thanks to this, memory corruption is much easier to detect and debug on OpenBSD.
- umanwizard 9y agoIsn’t malloc based on mmap (or some similar equivalent like mach_vm_allocate) in all systems?
- rurban 9y agoYes, we know that OpenBSD is famous for ignoring performance. A syscall for every tiny malloc, where in normal systems the threshold is 128K.
- quotemstr 9y agoExcept it doesn't use a syscall for every malloc. That would be crazy. It's a conventional block allocator.
- krylon 9y agoNot sure why you are getting downvoted. IIRC, OpenBSD is slightly more sophisticated than issuing one syscall per call to malloc(3) and friends. Just slightly, but still. ;-) Still, I do not like expressing disagreement by downvoting. Sorry about that.
- rurban 9y agoYeah, I was a bit wrong. It does a syscall for every 4K. Normal systems use a slow syscall only for malloc > 128K. I see no other advantage than extremism in security, and giving a damn about performance.
- chrisseaton 9y agoI think so in practice, but you could also use brk and sbrk.
- quotemstr 9y agoYeah, but brk amounts to the same thing, just worse in every way.
- zokier 9y agoglibc malloc uses brk for small allocations (<128k) on Linux
- slededit 9y agoWindows also has this with Page Heap mode. https://msdn.microsoft.com/en-us/library/ms220938(v=vs.90).aspx https://msdn.microsoft.com/en-us/library/ms220938(v=vs.90).a...