It is said that an unordered_map<int,int>
takes up much more space than a vector<int>
. While I am completely aware of that, I would like to know how to get the approximate size of a single instance of an unordered_map
in C++. For now, let's say that I inserted n = 1000000
elements into it. I presume that the memory taken up is n
multiplied by some kind of constant, I am, however, unable to find an accurate answer anywhere on the Internet.
Here is what I'm doing. I'd like to calculate how much memory u_m
uses, without writing any code. Is there a way to do that?
#include<bits/stdc++.h>
using namespace std;
const int N = 1000000;
unordered_map<int,int> u_m ;
int main(){
for(int i = 0;i<N;i++){
u_m[i] = 123+i;
}
return 0;
}
If that makes a difference, I intentionally put u_m
outside of main