I understand that Clean-Up is good thing to do. I also understand OS internals, so if I know my process is terminating then its memory will be freed. But I like to propose different perspective. I am on the lines it is rather BAD idea to free the memory on exit.
For e.g. I may have allocated large memory which is currently swapped out, if I free it up on exit, it rather needs to be brought to RAM, then free it. If I don;t, on exit it will simply be marked free in one table.
Overall, OSes have changed a lot(basics remain the same), I understand this question can be thought of A_VERY_PLATFORM_DEPENDENT, but from the perspective of application developer today, he is either stuck(?) into some framework, or the daredevil coder, who is working on raw technologies as COM, is significantly relied on, i would call VERY_CONTROLLED_ENVIRONMENT.
For TL;DR
: On modern OSes, I think I should NOT perform clean up on exit. If you think I am wrong, why?
PS: I am NOT talking about RTOSes, I meant controlled environment means Windows, Linux and I never meant Device driver development or for that matter OS development.
Memory blocks that have been swapped out will be brought in only when you access them. Freeing a block is a "bookkeeping" event, which does not require memory access. You are not going to gain anything by skipping the call to free memory.
Reasons to always free your resources manually on exit are much stronger: it lets you use tools for memory profiling, because you can distinguish unintended leaks from the intentional ones. That reason alone is good enough to recommend against skipping memory cleanup.