virtualalloc

Any way to reserve but not commit memory in linux?

て烟熏妆下的殇ゞ 提交于 2019-11-27 18:32:01
Windows has VirtualAlloc, which allows you to reserve a contiguous region of address space, but not actually use any physical memory. Later when you want to use it (or part of it) you call VirtualAlloc again to commit the region of previously reserved pages. This is actually really useful, but I want to eventually port my application to linux - so I don't want to use it if I can't port it later. Does linux have a way to do this? EDIT - Use Case I'm thinking of allocating 4 GB or some such of virtual address space, but only committing it 64K at a time. This would give me a zero-copy way to grow

Any way to reserve but not commit memory in linux?

[亡魂溺海] 提交于 2019-11-26 22:41:41
问题 Windows has VirtualAlloc, which allows you to reserve a contiguous region of address space, but not actually use any physical memory. Later when you want to use it (or part of it) you call VirtualAlloc again to commit the region of previously reserved pages. This is actually really useful, but I want to eventually port my application to linux - so I don't want to use it if I can't port it later. Does linux have a way to do this? EDIT - Use Case I'm thinking of allocating 4 GB or some such of