When allocating dynamic memory I have learned that it is important to delete the memory allocation before the program ends. What happens to dynamic allocated memory when assert() is used somewhere in the program if the call to assert results in the program exiting?
What happens to dynamic allocated memory when assert() is used
The operating system releases the resources used by the program when the program terminates. The heap is simply part of the program's data space.
By always matching new and delete calls, you create a methodology to prevent memory leaks. This may seem obvious in a simple linear program. Preventing memory leaks becomes very important in complex programs where objects are created and destoryed in a non-linear fashion. If memory leaks exist, it's possible to exhaust the heap and cause new or malloc calls to fail.