mmap a large range of memory which is larger than the total size of physical memory and swap
Posted on In QAHow to make mmap() a large range of memory which is larger than the total size of physical memory and swap successfully?
Short answer:
Adding the MAP_NORESERVE flag to mmap() to make it not reserve any swap space for the mapping.
For example:
rr_addr = mmap((void*)i, len, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
More details in: http://stackoverflow.com/questions/4803152/mmap-fails-when-length-is-larger-than-4gb