There have been some very good articles on the size of a map. However as a
map grows, it initial size become less important and the size per entry
is what matters.
How are the sizes measuredIn these tests an int key and long values are used. This adds a small but realistic size to each entry.
Size per entry of a medium sized MapThe following are the size per entry in bytes. The Map has 1024 entries.
|Type of Map||32-bit||64-bit compressed||64-bit not compressed|
The Javolution FastMap needed to be recycled. If it is not recycled, it was the largest per entry.
ConclusionIt may be worth considering The GNU Trove collections if you have primitive keys and/or values. However if you have non-trivial keys or values classes, the size of the collection is less likely to matter.