4 ms·
> In order to initialize this heap, a section of memory must be provided. In this repository, that memory is supplied by malloc (yes, allocating a heap via heap
by masklinn 9y ago
> In order to initialize this heap, a section of memory must be provided. In this repository, that memory is supplied by malloc (yes, allocating a heap via heap). In an OS setting some pages would need to be mapped and supplied to the heap (one scenario).
brk/sbrk is a bit of a pain but would it really be more complicated to use mmap?
- bjourne 9y agommap isn't available on Windows. On those platforms it is available on, there could be subtle differences. If you don't care about memory protection, there is no reason not to use malloc.
- slededit 9y agoIt's there in spirit. VirtualAlloc is extremely flexible. brk is really intended for a segmented environment but it makes it almost impossible to return commit back to the OS. A lot of unicies allow over commit because of this where windows will fail the alloc. The windows design is much better if you care about handling OOM.