title: Why deallocating heap memory is much slower than allocating it?
body: <p>This is an empirical assumption (that allocating is faster then de-allocating).</p>
  
  <p>This is also <strong>one</strong> of the reason, i guess, why heap based storages (like <em>STL</em> containers or else) choose to not return currently unused memory to the system (that is why <em>shrink-to-fit</em> idiom was born).</p>
  
  <p>And we shouldn't confuse, of course, '<em>heap</em>' memory with the '<em>heap</em>'-like data structures.</p>
  
  <hr>
  
  <p>So <strong>why de-allocation is slower</strong>?</p>
  
  <p>Is it <em>Windows</em>-specific (i see it on <em>Win 8.1</em>) or <em>OS</em> independent?</p>
  
  <p>Is there some C++ specific memory manager automatically involved on using '<em>new</em>' / '<em>delete</em>' or the whole mem. management is completely relies on the OS? (i know <em>C++11</em> introduced some garbage-collection support, which i never used really, better relying on the old <em>stack</em> and <em>static</em> duration or self managed <em>containers</em> and <em>RAII</em>).</p>
  
  <p>Also, in the code of the <em>FOLLY string</em> i saw using old C heap allocation / deallocation, is it faster then C++ '<em>new</em>' / '<em>delete</em>'?</p>
  
  <hr>
  
  <p><strong>P. S.</strong> please note that the question is <strong>not</strong> about <em>virtual memory</em> mechanics, i understand that <em>user-space</em> programs didn't use real mem. addresation.</p>