I have a weird problem with vector in C++..
I created a vector and inserted 10000 integer values into it and have checked the memory utilization. It is 600 kb. But after
The only way to really get rid off unused memory in a std::vector<> pre C++11 is to swap it with an empty vector: vector().swap(myvec). In C++11 you have a member function shrink_to_fit which often is implemented as the swap idiom just mentioned.
std::vector<>
vector().swap(myvec)
shrink_to_fit