Is it up to the programmer to deallocate on exit()?

前端 未结 4 589
不知归路
不知归路 2020-12-21 09:53

I have a program and when I input wrong data from the keyboard it just exits with exit(1).

I was testing with Valgrind and while this happens there are

4条回答
  •  我在风中等你
    2020-12-21 10:28

    In the end, the OS will take care of it (on every modern OS, it was not the case with older version of Windows). Every ressource used by your program (memory, open file descriptors, ...) will be reclaimed by the OS when the program terminate (except some resource that are designed to survive process termination, mainly some sort of shared memory / mutex).

    However, valgrind is here to help you track memory leak and will report every available memory region so that you can, if you want, manually release them.

提交回复
热议问题