If one allocates memory using anonymous memory mapping using mmap system call on linux:
mmap(NULL, 512*4096, MAP_READ|MAP_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
I was wondering if the mapped memory was prefaulted or if physical page is actualy allocated only when the program will access the mapped virtual memory?
I ask this because at the time of the mapping I do not know if the program will actualy use all the allocated memory. So if the kernel actualy allocates physical memory for anonymous mapping only when the memory is accessed, I do not have to worry about exhausting physical memory.