M
mygulamali
Hi all!
So I'm trying to determine how much memory is being used by the
following class member in my code:
vector<map<unsigned int, double> >
Would the snippet below be the right way of going about this?
---- BEGIN SNIPPET ----
vector<map<unsigned int,double> > my_data
// fill my_data up with some, erm... data, then...
int mem_used(0);
mem_used += sizeof(vector<map<unsigned int,double> >);
mem_used += my_data.capacity()*sizeof(map<unsigned int,double>);
for (int i=0; i<my_data.size(); i++) mem_used +=
my_data.size()*(sizeof(unsigned int)+sizeof(double));
---- END SNIPPET ----
Would appreciate your comments and suggestions as a sanity check.
Thanks in advance!
So I'm trying to determine how much memory is being used by the
following class member in my code:
vector<map<unsigned int, double> >
Would the snippet below be the right way of going about this?
---- BEGIN SNIPPET ----
vector<map<unsigned int,double> > my_data
// fill my_data up with some, erm... data, then...
int mem_used(0);
mem_used += sizeof(vector<map<unsigned int,double> >);
mem_used += my_data.capacity()*sizeof(map<unsigned int,double>);
for (int i=0; i<my_data.size(); i++) mem_used +=
my_data.size()*(sizeof(unsigned int)+sizeof(double));
---- END SNIPPET ----
Would appreciate your comments and suggestions as a sanity check.
Thanks in advance!