How can I reserve virtual memory in Linux?

寵の児 提交于 2019-12-01 09:50:17

I believe you should be able to achieve the same by mapping anonymous memory with PROT_NONE. Accessing PROT_NONE memory will result in a segfault, but the memory region will be reserved and not used for any other purpose. If you want to allocate a very big chunk of memory, add MAP_NORESERVE to ensure that the default overcommit mechanism won't check your allocation.

PROT_NONE is commonly employed for "guard" pages at the end of stacks.

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