J
Joseph Turian
Fellow hackers,
Is it possible to shrink the capacity of a vector?
i.e. Without new'ing and delete'ing a vector, can one return its memory
to the heap?
Here's what I get under the g++ implementation:
vector<double> v = vector<double>(1024*1024);
cerr << v.capacity() << "\n"; // outputs 1048576
v.clear();
cerr << v.capacity() << "\n"; // outputs 1048576
v = vector<double>();
cerr << v.capacity() << "\n"; // outputs 1048576
Joseph
Is it possible to shrink the capacity of a vector?
i.e. Without new'ing and delete'ing a vector, can one return its memory
to the heap?
Here's what I get under the g++ implementation:
vector<double> v = vector<double>(1024*1024);
cerr << v.capacity() << "\n"; // outputs 1048576
v.clear();
cerr << v.capacity() << "\n"; // outputs 1048576
v = vector<double>();
cerr << v.capacity() << "\n"; // outputs 1048576
Joseph