R
Richard Heathfield
Olivier said:
As a matter of good programming practice, a professional programmer prefers
specifically to release any memory that he or she has allocated.
Nevertheless...
....a decent modern protected-mode operating system is extremely unlikely to
allow a program to consume Megabytes of memory and then die with the memory
still allocated - it's going to want that memory back. So yes, the OS will
in all likelihood grab the memory when the program quits. But the C
Standard does not mandate this, and there may well be occasional systems
that don't do it, but you are unlikely to run into them.
Both!
<snip>
When quitting, a good
amount of memory is still allocated:
As a matter of good programming practice, a professional programmer prefers
specifically to release any memory that he or she has allocated.
Nevertheless...
is
it restored when the program terminates?
....a decent modern protected-mode operating system is extremely unlikely to
allow a program to consume Megabytes of memory and then die with the memory
still allocated - it's going to want that memory back. So yes, the OS will
in all likelihood grab the memory when the program quits. But the C
Standard does not mandate this, and there may well be occasional systems
that don't do it, but you are unlikely to run into them.
I mean, does the OS take care of that
or should I carefully deallocate everything?
Both!
<snip>