So I have a few vector collections below that are in different files and I'm having trouble figuring out how to deallocate them. I have my attempts below and put them all in the same destructor to reduce space, but when I check for memory leaks there are a BUNCH of errors and leaks detected. I was wondering if someone could confirm if I'm freeing memory for each of the collections below correctly? I'm used to working with arrays instead so I've been confused.
When a function looses scope any vector defined in that scope will automatically call the default dtor and destroy the vector before the function ends. This would apply to any STL class available and used in a program.
if you are done with it, see if you can arrange the code so it goes out of scope when you are done, and it will free its own memory then.
the actual memory may stay in place (this is efficient, you don't want to reallocate to nothing then stick stuff back into it. If you want to FORCE it to release the memory:
use this after clear: http://www.cplusplus.com/reference/vector/vector/shrink_to_fit/
methods that resize (change capacity) vectors are inefficient by nature. It is best to avoid resizing them as much as possible.