EhCache version: 2.8.4
JVM version: 11.0.7
Cache configuration:
<ehcache>
<cache
name="myCache"
maxBytesLocalHeap="100m"
eternal="true"
overflowToOffHeap="false"
overflowToDisk="true"
diskPersistent="false"
maxEntriesLocalDisk="2000000"
/>
</ehcache>
I've noticed when using a cache that overflows to disk (like in the above configuration) that there is a DiskStore object in memory which seems to grow indefinitely. I thought that limiting the number of entries on disk using maxEntriesLocalDisk
might prevent this from happening, but it does not appear to be helping.
Recently I looked at a heap dump from my application, and I can see that there are over 17M cache keys referenced by the DiskStore despite the maxEntiresLocalDisk
value being set to 2M. This is consuming over 2.5GB of memory which is not ideal given the application is only allocated 4GB of heap.
Is there some way to limit how many cache keys are referenced by the DiskStore in order to prevent it from getting so large? I'm considering calling Cache.evictExpiredElements()
on some kind of schedule to see if it helps, but was hoping maxEntriesLocalDisk
would prevent needing to do that. I'm actually sure if the entries are are expired, so it's possible evictExpiredElements
won't help.