Monday, March 3, 2014

Notes on Java Common Data Structures: Map

HashMap
http://java-performance.info/memory-consumption-of-java-data-types-2/
transient Entry<K,V>[] table = (Entry<K,V>[]) EMPTY_TABLE;
The default (new HashMap<>()) size of array of entries is 16 / 0.75 = 21.33 ~ 22.

ConcurrentHashMap
The ConcurrentHashMap splits the bucket table into a number of segments, thus reducing the probability that you would have contention when modifying the map. It is quite a clever design and scales nicely to about 50 cores. 

No comments:

Post a Comment