F
Felix E. Klee
Hi,
why does the memory consumption of the program attached below increase
steadily during execution? Shouldn't vector::reserve() allocate one
large memory chunk of memory that doesn't change anymore?
CPU: Pentium III Coppermine (Celeron)
OS: Slackware LINUX 9.1 with kernel 2.4.22
Compiler: 3.2.3
Compile command: g++ -O0 -o foo foo.cpp
Tools used to check memory consumption: top and xosview
Felix
foo.cpp:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
vector<double> vect;
vect.reserve(50l*1000000l);
for (int i = 0; i < 50; ++i) {
for (long j = 0; j < 1000000; ++j)
vect.push_back(sin(j*0.34543));
cout << "vect.capacity()=" << vect.capacity()
<< "vect.size()=" << vect.size()
<< endl;
}
return 0;
}
PS: To contact me off list don't reply but send mail to "felix.klee" at
the domain "inka.de". Otherwise your email to me might get automatically
deleted!
why does the memory consumption of the program attached below increase
steadily during execution? Shouldn't vector::reserve() allocate one
large memory chunk of memory that doesn't change anymore?
CPU: Pentium III Coppermine (Celeron)
OS: Slackware LINUX 9.1 with kernel 2.4.22
Compiler: 3.2.3
Compile command: g++ -O0 -o foo foo.cpp
Tools used to check memory consumption: top and xosview
Felix
foo.cpp:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
vector<double> vect;
vect.reserve(50l*1000000l);
for (int i = 0; i < 50; ++i) {
for (long j = 0; j < 1000000; ++j)
vect.push_back(sin(j*0.34543));
cout << "vect.capacity()=" << vect.capacity()
<< "vect.size()=" << vect.size()
<< endl;
}
return 0;
}
PS: To contact me off list don't reply but send mail to "felix.klee" at
the domain "inka.de". Otherwise your email to me might get automatically
deleted!