Say I allocate a big memory (40MB) with mmap using /dev/zero as follows.
fd = open(\"/dev/zero\", O_RDWR);
a = mmap (0, 4096e4, PROT_READ | PROT_WRITE, MAP_
Yes, even more the pages are only brought into existence if you touch them for the first time.
BTW, there is the flag MAP_ANONYMOUS
that you can use in this situation, no need to open a file descriptor on /dev/null
.
Both mmap /dev/zero and ANONYMOUS don't have file backed, also zeroed content. Look at the following link http://man7.org/linux/man-pages/man2/mmap.2.html