Reputation: 23
I am facing an issue where gridgain doe not seem to evict entries to offheap but simply discard it. My configuration for cache is
<bean id="test-cache" class="org.gridgain.grid.cache.GridCacheConfiguration">
<property name="name" value="testCache"/>
<property name="cacheMode" value="LOCAL" />
<property name="memoryMode" value="ONHEAP_TIERED"/>
<property name="swapEnabled" value="false"/>
<property name="offHeapMaxMemory" value="#{1024 * 1024 * 1024 * 3}"/>
<property name="evictionPolicy">
<!-- LRU eviction policy. -->
<bean class="org.gridgain.grid.cache.eviction.lru.GridCacheLruEvictionPolicy">
<property name="maxSize" value="40000"/>
</bean>
</property>
</bean>
I start inserting 1 million entries n the cache, but at the end of the put operations, I see 40,000 entries onheap (using size()) and 0 entries in off heap (using offHeapEntriesCount()). I am not able to iterate on anything offheap either indicating the others were discarded. I was hoping to find then in off heap storage.
Upvotes: 1
Views: 89
Reputation: 23
I figured out the issue. It was actually 3GB of allocation but the spring expression considered it as an Integer and breached the maximum integer value causing the allocation size to be negative. It got fixed with
<property name="offHeapMaxMemory" value="#{1024L * 1024L * 1024L * 3L}"/>
Upvotes: 1
Reputation: 2292
At a first glance, offHeapMaxMemory
is the actual memory size in bytes, so you are allocating only 3MB of memory off-heap, which is very small.
Try setting offHeapMaxMemory
to zero (0), which means no limit, and see if you get the expected behavior.
Upvotes: 1