title: Force free() to return malloc memory back to OS
body: <p>Seems like even after I free all the memory for a Linux process that was allocated by <code>malloc()</code>,
  memory is still reserved for the process and not returned to the OS.</p>
  <p>Running <code>valgrind massif</code> tool by default reveals no leakages.</p>
  <p>Running <code>valgrind</code> with <code>--pages-as-heap=yes</code> reveals this:</p>
  <blockquote>
  <p>-&gt;13.77% (7,655,424B) 0x35FEEEB069: brk (brk.c:31)</p>
  <p>-&gt;13.77% (7,655,424B) 0x35FEEEB113: sbrk (sbrk.c:53)</p>
  <p>-&gt;13.77% (7,655,424B) 0x35FEE82717: __default_morecore (morecore.c:48)</p>
  <p>-&gt;13.77% (7,655,424B) 0x35FEE7DCCB: _int_malloc (malloc.c:2455)</p>
  <p>-&gt;13.77% (7,655,424B) 0x35FEE7F4F1: malloc (malloc.c:2862)</p>
  </blockquote>
  <p>so even though memory was already freed by <code>free()</code>, it seems that <code>malloc</code> called <code>brk/sbrk</code> and did not return this to the OS.</p>
  <p>how can I force <code>free()</code> to call <code>sbrk()</code> immediately and return all memory back to the OS ?</p>
  <p>I am running on a very low end platform which every MB counts.</p>
  <p>Thanks in advance.</p>