/** * {@inheritDoc} */ @Override public long getSizeOfIntegerObject() { long size = this.getSizeOfObjectHeader() + INT_SIZE; return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOfCharacterObject() { long size = this.getSizeOfObjectHeader() + CHAR_SIZE; return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOfLongObject() { long size = this.getSizeOfObjectHeader() + LONG_SIZE; return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOfBooleanObject() { long size = this.getSizeOfObjectHeader() + BOOLEAN_SIZE; return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOfObjectObject() { return alignTo8Bytes(this.getSizeOfObjectHeader()); }
/** * {@inheritDoc} */ @Override public long getSizeOfShortObject() { long size = this.getSizeOfObjectHeader() + SHORT_SIZE; return alignTo8Bytes(size); }
/** * @return Size of concurrent hash map node in java 8. */ private long getSizeOfConcurrentHashMapNode() { long size = this.getSizeOfObjectHeader() + this.getPrimitiveTypesSize(3, 0, 1, 0, 0, 0); return alignTo8Bytes(size); }
/** * Returns size of HashMap's inner Key or Entry set classes. * * @return Returns size of HashMap's inner Key or Entry set classes. */ @Override public long getSizeOfHashMapKeyEntrySet() { // since these are inner classes, one reference to enclosing class is needed long size = this.getSizeOfObjectHeader() + this.getPrimitiveTypesSize(1, 0, 0, 0, 0, 0); return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOfCustomWeakReference() { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(4, 0, 0, 0, 1, 0); return alignTo8Bytes(size); }
/** * Returns the size of a HashMap entry. Not that the key and value objects are not in this size. * If HashSet is used the HashMapEntry value object will be a simple Object, thus this size has * to be added to the HashSet. * * @return Returns the size of a HashMap entry. Not that the key and value objects are not in * this size. If HashSet is used the HashMapEntry value object will be a simple Object, * thus this size has to be added to the HashSet. */ private long getSizeOfHashMapEntry() { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(3, 0, 1, 0, 0, 0); return alignTo8Bytes(size); }
/** * Calculates the size of the array with out objects in the array - <b> Can only be used on * non-primitive arrays </b>. * * @param arraySize * Size of array (length). * @return Size in bytes. */ @Override public long getSizeOfArray(int arraySize) { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(arraySize, 0, 1, 0, 0, 0); return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOf(String str) { if (null == str) { return 0; } long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(1, 0, 2, 0, 0, 0); size += this.getSizeOfPrimitiveArray(str.length(), CHAR_SIZE); return alignTo8Bytes(size); }
/** * Calculates the size of the primitive array with the primitives in the array. * * @param arraySize * Size of array (length). * @param primitiveSize * Size in bytes of the primitive type in array * @return Size in bytes. */ @Override public long getSizeOfPrimitiveArray(int arraySize, long primitiveSize) { long size = this.getSizeOfObjectHeader() + INT_SIZE; if (ALLIGN_CLASS_CALCULATION) { size = alignTo8Bytes(size); } size += arraySize * primitiveSize; return alignTo8Bytes(size); }
/** * Returns size of the CAT object used in the high scale lib Counter. * * @return Size in bytes. */ private long getSizeOfHighScaleLibCAT() { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(2, 0, 0, 0, 4, 0); size = alignTo8Bytes(size); // always has an array of 4 longs attached size += this.getSizeOfPrimitiveArray(4, LONG_SIZE); return size; }
/** * Returns size of the Counter object used in the high scale lib NonBlockingHashMapLong. * * @return Size in bytes. */ private long getSizeOfHighScaleLibCounter() { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(1, 0, 0, 0, 0, 0); size = alignTo8Bytes(size); size += this.getSizeOfHighScaleLibCAT(); return size; }
/** * {@inheritDoc} */ @Override public long getSizeOf(List<?> arrayList, int initialCapacity) { if (null == arrayList) { return 0; } int capacity = getArrayCapacity(arrayList.size(), initialCapacity); long size = alignTo8Bytes(this.getSizeOfObjectHeader() + this.getPrimitiveTypesSize(1, 0, 2, 0, 0, 0)); size += this.getSizeOfArray(capacity); return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOf(Timestamp timestamp) { if (null == timestamp) { return 0; } // 72 is the number of bytes for instance of GregorianCalendar // inside Timestamp. However, I can not check if this is null or not. // In our objects I never found it to be instantiated, so I don't include it. long size = this.getSizeOfObjectHeader(); // java.sql.Timestamp size += this.getPrimitiveTypesSize(0, 0, 1, 0, 0, 0); // java.util.Date size += this.getPrimitiveTypesSize(1, 0, 0, 0, 1, 0); return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOfHashSet(int hashSetSize, int initialCapacity) { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(1, 0, 0, 0, 0, 0); size += this.getSizeOfHashMap(hashSetSize, initialCapacity); // One object is used as the value in the map for all entries. This object is shared between // all HashSet instances, but we have to calculate it for each instance. if (hashSetSize > 0) { size += this.getSizeOfObjectObject(); } return alignTo8Bytes(size); }
/** * {@inheritDoc} */ @Override public long getSizeOfNonBlockingHashMapLong(int mapSize) { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(5, 1, 0, 0, 1, 0); size = alignTo8Bytes(size); // we have in addition Counter, no-key Object and CHM table in the NonBlockingHashMapLong // need to add them to the size count size += this.getSizeOfObjectObject(); size += this.getSizeOfHighScaleLibCounter(); size += this.getSizeOfHighScaleLibCHM(mapSize); return size; }
/** * {@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); }