On Mon, 7 Nov 2016 at 09:32 Ram
Thanks Juan! What I am interested in here is mainly to get the size of the housekeeping. The key(string) and the value(pointers to class objects) are of reasonable size and that is fine. I want to see how much overhead the housekeeping causes when my unordered_map is huge. I am trying to decide between a std::map and boost::unordered_map.
A strategy that might give you what you want is to overload global new and
delete and then write some code to log the allocations. From there you can
calculate the total amount of memory consumed and subtract out the expected
amount of memory from the logged data. Something like the code below is
close, but keep in mind that this is an example and there are many
overloads for new and delete (nothrow versions, etc) so you will need to
make sure that these are the versions being called. This test also doesn't
account for allocator overhead and will probably only work on Windows
because it uses the platform specific _msize function. On Linux,
malloc_usable_size might do the trick instead of _msize.
#include <map>
#include <iostream>
#include