/** * {@inheritDoc} */ @Override public long getSizeOfConcurrentHashMap(int mapSize) { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(8, 0, 3, 0, 1, 0); // in Java 8 map table is not initialized when empty if (mapSize > 0) { int initialCapacity = MAP_INITIAL_CAPACITY; initialCapacity = tableSizeFor(initialCapacity + (initialCapacity >>> 1) + 1); int tableSize = getConcurrentMapCapacityFromSize(mapSize, initialCapacity); // array of nodes based on tableSize size += this.getSizeOfArray(tableSize); // and for each object in the map there is the reference to the HashEntry in Segment // that we // need to add // size += mapSize * alignTo8Bytes(this.getReferenceSize()); size += mapSize * this.getSizeOfConcurrentHashMapNode(); } return alignTo8Bytes(size); }