Thrown exceptions can interrupt the normal control flow of a program, sometimes leaving behind dynamically allocated mem
Posted: Fri Apr 29, 2022 8:01 am
Thrown exceptions can interrupt the normal control flow of a program, sometimes leaving behind dynamically allocated memory that is not released. What is considered the best way to prevent memory leaks when an exception is thrown? None of these. Storing the memory to be released in a catch parameter to be deleted by whoever catches it Using objects within functions and having the object destructor release the memory. Having each function that must release memory institute its own try/catch block where it can delete the memory.