I guess it's more of a general question about processes in an operating system, but it also fits into here, I think.
Suppose I run a program that allocates heap memory, never frees it, but then exits.
Correct me if I'm wrong, but whenever a process exits, the OS deallocates (almost) every memory chunks that are associated with it; including its heap, stack, and PCB. So, in that case, harm can only be done by programs that 'run in background' for a long period of time, and consume memory they do not actually use or need.
Putting aside the risk of acquiring a bad habit, in terms of memory usage, what is the harm of not freeing heap memory in programs that are designated to perform a specific (small) task?
I mean, for something as simple as:
Code:int main(int argc, char* argv[]) { // do some specific task that consumes heap memory return 0; }