Basically you can:
- calculate it by theory:
- look at the HashMap implementation to find out what this method does.
- Look at the implementation of the virtual machine to find out how much space the individual created objects take.
- Measure it somehow.
Most of the other answers relate to the second method, so I will consider the first (in OpenJDK source, 1.6.0_20).
capacity
, >= initialCapacity, , 1048576 = 2 ^ 20 .
new Entry[capacity]
table
. ( ).
, HashMap ( 3 ints, float ) Entry []. ( ) (, ).
, , . - 32- 32 (= 4 ), 64- 64 (= 8 ).
, 32- 4 , 64- 8 , .
HashTable , Entry
. int , 24 32- , , . , 1000000- HashMap ( > 1) ~ 28 32- ~ 56 64- .
, .