title: Is memory being freed when calling exec(3) an implementation detail?
body: <p>From what I've read, the general consensus seems to be that you don't need to free memory before running <code>exec(3)</code>. However, in the <a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html" rel="nofollow">POSIX standard</a>, handling of the heap / malloc memory does not seem to be explicitly detailed. I know it's common for people to not bother freeing memory when an application is exiting because the OS will clean up the data, but from what I understand, that's an OS implementation detail; the OS is not <strong>required</strong> to free the memory even though many modern systems do. Is this also the case with <code>exec(3)</code>? I'm wondering if freeing <code>malloc</code>'d memory before <code>exec(3)</code> is the right thing to do even though it's not necessary for many modern operating systems.</p>