Any way to reserve but not commit memory in linux?

前端 未结 4 1223
南方客
南方客 2020-12-01 03:00

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

4条回答
  •  不思量自难忘°
    2020-12-01 03:22

    The Linux equivalent of VirtualAlloc() is mmap(), which provides the same behaviours. However as a commenter points out, reservation of contiguous memory is the behaviour of calls to malloc() as long as the memory is not initialized (such as by calloc(), or user code).

提交回复
热议问题