When a hash table is initialized how is memory is allocated for it? When we add new members to it how does the memory used by the hash table get extended? Does it ever happen that a hash table is not able to store objects after a fixed size?
Share
You can use .NET reflector to find out.
System.Collections.Hashtable has some hard limits in it:
Also keep in mind the value of
int.MaxSizefor capacity (I think capacity might be the same as the bucket count, depending on load factor).If you’re hitting that size limit, though, you may want to look into better storage methods than an in-memory hash table CLR object…
Edit:
Memory for the hash table is allocated in this manner:
See Will’s answer for what
HashHelpers.GetPrimedoes.