When and how is mmap'ed memory swapped in and out? : <p>In my understanding, mmap'ing a file that fits into RAM will be like having the file in memory.</p>

<p>Say that we have 16G of RAM, and we first mmap a 10G file that we use for a while. This should be fairly efficient in terms of access. If we then mmap a second 10G file, will that cause the first one be swapped out? Or parts of it? If so, when will this happen? At the mmap call, or on accessing the memory area of the newly loaded file?</p>

<p>And if we want to access the memory of the pointer for the first file again, will that make it load the swap the file in again? So, say we alternate reading between memory corresponding to the first file and the second file, will that lead to disastrous performance?</p>

<p>Lastly, if any of this is true, would it be better to mmap several smaller files?</p>
