std::hash_map consumes excessive memory?

  • Thread starter Thread starter David Chazin
  • Start date Start date
D

David Chazin

I have simple hash_map<int, int>. When I insert 1000 entries my memory
grows by about 2 MB (or almost 2k per entry). Anybody have any ideas
on whats going on here? This is a real problem because I need to store
about 1.3 million entries.
I am using Visual C++ 7.0.

David Chazin
 
Hello David,
Have you looked at the map size as you add items, it could
be that the map allocates 2MB as the 'initial chunk'. In
other words, no matter whether you add 100 or 1000 entries
the map will initially size to 2MB.
 
Back
Top