How does a memory mapped file work for files larger than memory?
<p>I'm trying to work with data file that is larger than my memory. </p>

<p>My understanding so far is that it maps every byte in the file to an address in virtual memory. The data is only read to the real memory when you actually need it (for example accessing a specific entry), and it is read in chunks that are called pages.</p>

<p>But if I'm eventually going to process everything in that data file, doesn't that mean that everything needs to be read into the real memory eventually? Does the OS automatically decide which parts of the data already in memory to be freed to make room for extra data?</p>

<p>For this specific project I'm working with Python on Linux if that makes any difference. numpy.memmap</p>