title: What happens to memory that is not freed after end of program?
body: <blockquote>
    <p><strong>Duplicate</strong>: <a href="https://stackoverflow.com/questions/654754/what-really-happens-when-you-dont-free-after-malloc">What REALLY happens when you don’t free after malloc?</a></p>
  </blockquote>
  
  <p>Let's say, for example:</p>
  
  <pre><code>int main()
  {
    char* test = new char[50000];
    return 0;
  }
  </code></pre>
  
  <p>What happens to the allocated memory after the program had finished? Does it get freed for other applications immediately? Or perhaps after some time? Or maybe it's lost to the system forever? Or does it get swapped to the disk never to return to RAM? Or maybe something completely different?</p>
  
  <p>I would like to know what happens on the major 3 OS's: Windows (XP and up, if there are any differences), Linux, Mac OS X.</p>