memory management - C++ vector reduce allocation size -
when c++ vector dynamically reduce allocated size in practice.
i know allocated space doubles upon insert full vector, it's not clear me when allocation reduced. classical hysteresis halve allocation size upon removal 1/4-full vector.
it never shrink allocated memory in absence of explicit direction so.
in c++11 there shrink_to_fit
call ask implementation this, may not reduce allocated memory. in prior versions have create new copy , swap away old one.
Comments
Post a Comment