int ourTableSize = ((AbstractObjectSizes) objectSizes).getMapCapacityFromSize(size, 16); tableCorrect = tableSize == ourTableSize;
/** * {@inheritDoc} */ @Override public long getSizeOfHashMap(int hashMapSize, int initialCapacity) { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(4, 0, 4, 1, 0, 0); int mapCapacity = this.getMapCapacityFromSize(hashMapSize, initialCapacity); // size of the map array for the entries // in java 8 hash map table is not initialized until first element is added if (mapCapacity > 0) { size += this.getSizeOfArray(mapCapacity); } // size of the entries size += hashMapSize * this.getSizeOfHashMapEntry(); // To each hash map I add 16 bytes because keySet, entrySet and values fields, that can each // hold 16 bytes // These fields are null until these sets are requested by user. // Thus I add for one size += getSizeOfHashMapKeyEntrySet(); return alignTo8Bytes(size); }