I create an off-heap cache and set the cache MaxMemoryOffHeap = 10M.
Then I put data to the cache and print the cache size, the cache size info as:
cache.size = 100
cache.size = 200
cache.size = 300
cache.size = 400
cache.size = 500
cache.size = 600
cache.size = 700
cache.size = 800
...
cache.size = 6800
cache.size = 6900
cache.size = 7000
cache.size = 7100
cache.size = 7200
cache.size = 7300
cache.size = 7400
cache.size = 7500
cache.size = 7600
cache.size = 7700
cache.size = 7800
cache.size = 7890
cache.size = 7874
cache.size = 7860
cache.size = 7775
cache.size = 7717
cache.size = 7580
cache.size = 7477
cache.size = 7401
cache.size = 7359
cache.size = 7300
cache.size = 7265
cache.size = 7232
...
Maybe the off-heap size not given enough, so the cache size reach 7890 then decrease.
My question is :
Why the cache size not keep at 7890 but decrease ?
What data will be removed when the cache size reached the maxmum?
And how can I control its?
Thanks.
The Cache.size you are printing here is giving the number of elements in cache and not the Offheap size. Few things here :
What is the element size you have , is it variable ? The eviction depend on size and if it's variable you may see more deviation from normal behavior.
As in your case once the number of elements are decreasing(breaching the defined size) it can be because of eviction. For this MemoryStoreEvictionPolicy attribute specified in the configuration file. Legal values are LRU (default), LFU and FIFO. You can refer to following link for more detail :
If you want to calculate the Offheap size you can use : CalculateOffHeapSize() but this has performance stakes so not recommended in production environment.
The Cache.size you are printing here is giving the number of elements in cache and not the Offheap size. Few things here :
What is the element size you have , is it variable ? The eviction depend on size and if it's variable you may see more deviation from normal behavior.
As in your case once the number of elements are decreasing(breaching the defined size) it can be because of eviction. For this MemoryStoreEvictionPolicy attribute specified in the configuration file. Legal values are LRU (default), LFU and FIFO. You can refer to following link for more detail :
If you want to calculate the Offheap size you can use : CalculateOffHeapSize() but this has performance stakes so not recommended in production environment.