title: Understanding memory allocations
body: <p>I'm trying to understand "how memory works". As far as I understand the OS (Linux in my case) when calling <code>mmap</code> to create <code>MAP_ANONYMOUS</code> mapping it creates:</p>
  
  <blockquote>
    <p><code>mmap()</code> creates a new mapping in the virtual address 
    space of the calling process</p>
  </blockquote>
  
  <p>As far as I know virtyal address space of a process may exceed tge actual physical memory available.</p>
  
  <p>Also as far as I know the actual mapping to a physical memory occurs when <code>CPU</code> triggers page fault when it tries to access to a memory page that is not in page table yet. </p>
  
  <p>OS catches the page fault and creates an entry in a page directory.</p>
  
  <p>What <em>should</em> happen if I <code>mmap</code>ed some anonymous memory (but did not touch any of the pages), then other processess exhausted all the physical memory and then I try to use one of the pages <code>mmap</code>ed (I have swap disabled)? </p>
  
  <p>CPU should trigger page fault and then try to create an entry in a page direcrory. But since no physical memory left it will not be able to do so...</p>