What happens to memory if you terminate a program

Does the OS free all the memory?
Yes.
With (most?) modern operating systems, the answer is yes.

On any O/S with a MMU (which includes Unix, Linux, OSX and the Windows NT family) the process has a data structure that is used to set up page mappings for tbe MMU. When the process is terminated this mapping is released and the pages are added to the Operating System's free pool.

On non protected-memory O/S platforms such as DOS or some realtime operating systems the memory may need to be explicitly freed and the O/S pool could possibly leak memory if it is not tidied up correctly.

From: What happens to memory that is not freed after end of program? [duplicate]
http://stackoverflow.com/questions/864204/what-happens-to-memory-that-is-not-freed-after-end-of-program

(MMU meaning Memory management unit
http://en.wikipedia.org/wiki/Memory_management_unit )

Also see

What REALLY happens when you don't free after malloc?
http://stackoverflow.com/questions/654754/what-really-happens-when-you-dont-free-after-malloc

Andy
Last edited on
Topic archived. No new replies allowed.