title: Is it possible to fork a process without inherit virtual memory space of parent process?
body: <p>As the parent process is using huge mount of memory, <code>fork</code> may fail with <code>errno</code> of <code>ENOMEM</code> under some configuration of kernel overcommit policy. Even though the child process may only <code>exec</code> low memory-consuming program like ls.</p>
  
  <p>To clarify the problem, when /proc/sys/vm/overcommit_memory is configured to be 2, allocation of (virtual) memory is limited to <code>SWAP + MEMORY * ration(default to 50%)</code>.
  When a process forks, virtual memory is not copied thanks to COW. But the kernel still need to allocate virtual memory space. As an analogy, fork is like malloc(virtual memory space size) which will not allocate physical memory and writing to shared memory will cause copy of virtual memory and physical memory is allocated. When overcommit_memory is configured to be 2, fork may fail due to virtual memory space allocation.</p>
  
  <p>Is it possible to <code>fork</code> a process without inherit virtual memory space of parent process in the following conditions?</p>
  
  <ol>
  <li><p>if the child process calls <code>exec</code> after <code>fork</code></p></li>
  <li><p>if the child process doesn't call <code>exec</code> and will not using any global or static variable from parent process. For example, the child process just do some logging then quit.</p></li>
  </ol>