In C, and C++, assuming that I’m not using smart pointers or any other weird garbage collecting mechanism, does memory get deallocated (garbage collected) when the program exits?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, any memory you don’t free will be automatically freed by the operating system when your program exits. This means it’s generally safe to call
exit()at any time, though you need to be careful about other resources that aren’t automatically freed, like global atoms on Windows and named pipes and others.