
26 Jul
2016
26 Jul
'16
9 p.m.
On 24 July 2016 at 14:44, Benedek Thaler <thalerbenedek@gmail.com> wrote:
Thanks for the feedback, Mathias. You are right. This implementation detail is a consequence of honoring reserve calls:
devector<int> d; d.push_back(1); d.reserve_front(100); d.reserve_back(100);
The reserve back has to keep the front capacity untouched or it breaks the promise of it. This also applies to a series of push_front/pop_backs, for example.
I think it's pretty serious. Consider: int n; devector<int> d; d.push_back(0); for(int i=0; i<n; ++i) { d.push_back(i); d.pop_front(); } You end up with ever growing memory consumption, despite the devector only containing one or two elements at all times.