mmap a large range of memory which is larger than the total size of physical memory and swap

How to make mmap() a large range of memory which is larger than the total size of physical memory and swap successfully?
asked Jan 19, 2013 by forum (2,150 points)

1 Answer

 
Best answer

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

answered Jan 20, 2013 by SA (14,760 points)
selected Jan 20, 2013 by SA

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...