title: Does malloc lazily create the backing pages for an allocation on Linux (and other platforms)?
body: <p>On Linux if I were to <code>malloc(1024 * 1024 * 1024)</code>, what does malloc actually do?</p>
  
  <p>I'm sure it assigns a virtual address to the allocation (by walking the free list and creating a new mapping if necessary), but does it actually create 1 GiB worth of swap pages? Or does it <code>mprotect</code> the address range and create the pages when you actually touch them like <code>mmap</code> does?</p>
  
  <p>(I'm specifying Linux because <a href="http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html" rel="noreferrer">the standard</a> is silent on these kinds of details, but I'd be interested to know what other platforms do as well.)</p>