This is the relevant part of my code:
//point A
std::vector<int> x;
//point B
x.reserve(100);
//point C
x.reserve(200);
//point D
At points A, B, C, and D I query for free physical memory (this is
platform dependent and I use GlobalMemoryStatus under Windows, but is
irrelevant here). The differences are what interests me because they
should tell me something about the memory cost of std::vector.
This is what I get:
B - A = 0 bytes, i.e. the vector declaration costs nothing
C - B = 4096, i.e. 100 integers cost 4 KB
D - C = 0, i.e. 200 integers cost the same as 100 integers
None of this makes much sense to me. Is this compiler dependent? At
point C x.capacity() reports 100, and at point D it reports 200. So
where are the catches?