1

I am taking a system programming class. The professor mentioned that in the case of returning EXIT_FAILURE, it is not necessary to free the memory allocated in the heap, because the will get reclaimed by the OS.

So my question is, in the case of returning EXIT_SUCCESS, does it live indefinitely? If not, what is the point of freeing the memory after your program terminates?

CJ Lin
  • 35
  • 4
  • 1
    No, it is still reclaimed, but it is good practice to free up the resources. For an emergency exit though, you might not easily know exactly what resources you need to hand back. – Weather Vane Apr 13 '20 at 19:19

0 Answers0