Should I free allocated memory on abnormal termination?

后端 未结 7 1611
無奈伤痛
無奈伤痛 2021-01-17 12:34

My program (a text-mode web browser) is dynamically allocating memory.

I do free unneeded blocks during runtime, of course. And I do free everything before normal te

7条回答
  •  感情败类
    2021-01-17 12:43

    You don't need to reclaim memory on normal termination except to obviate false positives in leak detecting tools.

    If your program terminates abnormally, depending on the cause, you may find that you can't free memory. For instance, a SIGSEGV resulting from a corrupted heap means that even trying to free other stuff on the heap maybe a hopeless exercise.

提交回复
热议问题