In the beginning of a C++ code, I initialize a vector of 1000000(a million) bool type data. However, in valgrind, the maximum heap + stack usage is shown 200Kb. Given that a Bool is 1 Byte, shouldn't it be 1 Mb ?
Is there an optimization that I don't realise ? Or am I missing something ?
Thanks is advance.
I use a Ubuntu64 16.04 system. Compiling the code without -O
parameter.
Edit: The code can be simplified to this,
vector<bool> * isPrime;
int main(){
isPrime = new vector<bool>(1000000, true);
}
Edit2: It seems there was an optimization that I don't realise (which is stated in the comments). Thanks.