Reserve memory on OS X

纵然是瞬间 提交于 2020-01-23 11:03:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!