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?

+3


source to share


5 answers


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

.



+2


source


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



+2


source


Does the OS reclaim memory when the application exits in C? Yes.

If you don't free memory: your application may end without memory and crash.

+2


source


Freeing memory before exiting is optional, because o / s will clean you up.

Freeing up unused memory while you are running is a good idea; this prevents running out of memory (and exiting the application). The difficulty often lies in the fact that the memory is not being used.

+2


source


Yes. But if your program is a long-term program, you will not only end up overwhelming your program, but as time progresses, you also slow down the system, assuming that you are using too much memory.

+2


source







All Articles