Walk me through how you would ensure that all dynamically allocated memory in a complex C++ application is properly released.