OS reclaims memory when application exits in C?
Possible duplicate:
When you exit the C application, is the malloc-ed memory automatically freed?
Pretty much a title. Do (modern) OSes automatically reclaim the allocated heap of memory at program termination? If so, frees memory of a strict or fairer kind?
What's the worst thing that can happen if I don't free an explicit memory deal, other than end up losing it while the app is running?
source to share
When the application exits, all memory will be reclaimed by the OS. The reason people preach memory management techniques is that as long as the application is running, any memory requested will remain in its position (even if it is no longer used). Unless, of course, you were good enough to call free
.
source to share
if app exits os, it will clean up memory and resources. unless you free the memory with free (), then the memory allocated by the heap will be used more and more as it is requested. if it continues, os will start using the swapfile / file for placement. it still continues os, will stop or stop application with some error
source to share