-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Memory overhead
The cache and entry objects only require certain fields depending on the configuration options specified when creating the cache. To minimize memory, code generation is used to avoid retaining unnecessary fields.
Estimates were performed using a Java instrumentation agent to calculate the runtime size. The size is may be affected by compressed references, object padding, etc. applied by the JVM. This benchmark may be run using gradle memoryOverhead
which executes MemoryBenchmark.
By forking Java 5's ConcurrentHashMap
, Guava has a slight advantage with per-entry optimizations. This is evident when weak and soft reference caching is used. Caffeine must retain additional fields to remove a collected entry due to decorating a Java 8 ConcurrentHashMap
.
Status:
- per-entry optimizations completed
- top-level optimizations pending
Cache | Baseline | Entry |
---|---|---|
Caffeine | 392 bytes | 54 bytes |
Guava | 1,136 bytes | 58 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,704 bytes | 74 bytes |
Guava | 1,560 bytes | 74 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,728 bytes | 82 bytes |
Guava | 1,560 bytes | 74 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,728 bytes | 90 bytes |
Guava | 1,728 bytes | 90 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,744 bytes | 82 bytes |
Guava | 27,472 bytes | 90 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,712 bytes | 74 bytes |
Guava | 1,552 bytes | 74 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,680 bytes | 82 bytes |
Guava | 1,560 bytes | 74 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,680 bytes | 82 bytes |
Guava | 1,360 bytes | 74 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,704 bytes | 98 bytes |
Guava | 1,728 bytes | 90 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,648 bytes | 98 bytes |
Guava | 1,416 bytes | 66 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,648 bytes | 98 bytes |
Guava | 1,416 bytes | 74 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,648 bytes | 130 bytes |
Guava | 1,512 bytes | 82 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,648 bytes | 138 bytes |
Guava | 1,584 bytes | 90 bytes |
Cache | Baseline | Entry |
---|---|---|
Caffeine | 85,648 bytes | 106 bytes |
Guava | 1,416 bytes | 82 bytes |