Excessive memory usage of large hash_maps

Paul Dubuc pdubuc@cas.org
Wed Nov 5 20:29:00 GMT 2003


Hash containers are apparently resized on based on a table of prime numbers 
(__stl_prime_list) in stl_hashtable.h.  As a hash table grows space (number of 
buckets) is reallocated based on the next higher number in this list.  The 
numbers roughly double with each increment.  This isn't noticable in the lower 
increments, but can result in a lot of wasted space in the larger ones.  Why 
should the size continue to double once we get above, say 98317?  Couldn't 
smaller increments be inserted here to conserve memory?  Better yet provide a 
nice way to override the __stl_next_prime() function?

-- 
Paul M. Dubuc



More information about the Libstdc++ mailing list