I use Ms Visual Studio2010 Express and have next code
set<string> res;
for(uint x = 0; x<100000;++x) res.insert( vtos(x,0) );
uint size1=0;uint size2=0;uint size3=0;
set<string>::const_iterator it=res.begin();
for(;it!=res.end();++it){
string str = *it;
size1+=str.size();
size2+=str.capacity();
size3+=str.capacity() + sizeof(string);
}
cout << "size1 == " << ((float)size1)/1024/1024 << endl;
cout << "size2 == " << ((float)size2)/1024/1024 << endl;
cout << "size3 == " << ((float)size3)/1024/1024 << endl;
while(true){}
The output for that is
size1 == 0.466242
size2 == 1.43051
size3 == 4.1008
The cycle ( in the end, it is bad thing, i know ) is only for watching TaskManager. In TaskManager I see that memory of my application is 6,11 Mb
Why is 6M? Where is ~2Mb?
If i replace set by vector( resized for 100000) the ouptput will be the same, but in task manager i see ~3,45Mb.
Why is 3 Mb?
Sorry for my poor English, thak you in advance.