hibernate/hibernate-orm — pull request #689 by Sanne (2014-02-18 12:53:56+00:00)
Title: HHH-8961  Reduce allocation cost of org.hibernate.cache.spi.CacheKey instances

https://hibernate.atlassian.net/browse/HHH-8961

The report by JOL is now less concerning:

org.hibernate.cache.spi.CacheKey object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
0 12 (object header) N/A
12 4 int CacheKey.hashCode N/A
16 4 Serializable CacheKey.key N/A
20 4 Type CacheKey.type N/A
Instance size: 24 bytes (estimated, the sample instance is not available)
Space losses: 0 bytes internal + 0 bytes external = 0 bytes total

And when multitenancy is being used:

org.hibernate.cache.internal.TenantAwareCacheKey object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
0 12 (object header) N/A
12 4 int CacheKey.hashCode N/A
16 4 Serializable CacheKey.key N/A
20 4 Type CacheKey.type N/A
24 4 String TenantAwareCacheKey.tenantId N/A
28 4 (loss due to the next object alignment)
Instance size: 32 bytes (estimated, the sample instance is not available)
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total