问题
What's the equivalent to Windows's VirtualAlloc in OS X? That is, how can i reserve a contiguous address space without actually commiting it and then commit chunks of it later?
Thanks,
Alex
回答1:
The mmap() function, called with MAP_ANON | MAP_PRIVATE, is very roughly equivalent to VirtualAlloc() with the MEM_RESERVE flag. Memory is then committed by touching each page in the mapping.
回答2:
No, unfortunately, there is no exact equivalent to VirtualAlloc.
来源:https://stackoverflow.com/questions/3561034/reserve-memory-on-os-x