|
|
|
|
|
by ninkendo
407 days ago
|
|
Malloc and free aren’t handled by the operating system, they’re handled in user space. Underneath malloc is mmap(2) (or in older unices, setbrk), which actually requests the memory. And with delayed/lazy allocation in the OS, you can just mmap a huge region up front, and it won’t actually do anything until you write/read to the individual pages. Point is, you only need one up front call to mmap to write to any page you want. |
|