Hacker News new | ask | show | jobs
by derefr 3464 days ago
1. The OS likes to fill physical memory with cache, rather than leaving it empty, because modern memories zero quickly enough for the OS to pretend it has "free memory", only actually freeing it on demand.

2. "Clean" mmap(2)ed pages count as "cache" in the above.

3. Memory allocations are usually physically contiguous—when you mmap(2) something, and then read every byte of that thing in order, that thing usually ends up in a contiguous run of physical memory as clean page-cache entries. This will be true to the extent that you have no other memory pressure forcing the page cache to fragment, evict other caches, or overwrite itself.

4. ASLR just juggled virtual-memory, not physical memory. IIRC (not a kernel dev), Linux at least has an allocation strategy that will effectively allocate physical memory serially if there's no contention.

Put 1-4 together, and you get a system where a big mmap(2)ed file that takes up all the physical memory of an otherwise-idle system, will end up putting that thing into the same places each time (because that's the only place such a large allocation will fit.)