Freeing in an atexit()
问题 Is there any point to freeing memory in an atexit() function? I have a global variable that gets malloc'ed after startup. I could write an atexit() function to free it, but isn't the system going to reclaim all that memory when the program exits anyway? Is there any benefit to being tidy and actively cleaning it up myself? 回答1: Not in C - it's like rearranging the deck chairs while the ship sinks around you. In C++ the answer is different, because objects can delete temporary files and so