Is freeing allocated memory needed when exiting a program in C

Any modern operating system will clean up everything after a process terminates, but it’s generally not a good practice to rely on this.

It depends on the program you are writing. If it’s just a command line tool that runs and terminates quickly, you may not bother cleaning up. But be aware that it is this mindset that causes memory leaks in daemons and long-running programs.

Leave a Comment