0
votes

I'm using Ignite engine as a bean inside a Spring boot web application. The cache configuration is as follows:

<bean id="ignite" class="org.apache.ignite.IgniteSpringBean">
<property name="configuration">
    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="cacheConfiguration">
            <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="atomicityMode" value="TRANSACTIONAL" />
                    <property name="cacheMode" value="PARTITIONED" />
                    <property name="backups" value="0" />
                    <property name="startSize" value="#{1024*16}" />
                    <property name="memoryMode" value="OFFHEAP_TIERED" /> 
                    <property name="offHeapMaxMemory" value="#{1 * 1024L * 1024L * 1024L}" />
                    <property name="swapEnabled" value="true" />
                    <property name="evictSynchronized" value="true" />
                </bean>
            </list>
        </property>


        <property name="swapSpaceSpi">
            <bean class="org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi">
                <property name="baseDirectory" value="..." />
            </bean>
        </property>

Here is the default memory usage after I start the engine with 0.5GB heap: enter image description here

Now at this point I'm expecting the maximum memory usage to be 2.6 GB since I set the off-heap max memory to 1 GB. But here is what happens after I load some million objects into cache! enter image description here

What's even worse is, I destroy the cache but the memory usage is still there! enter image description here

At this point if I try to load more entries into cache, the memory usage just keeps growing, proving that ignite didn't free the cache I destroyed earlier.

EDIT

I uploaded a maven test project along with my output to http://sourceforge.net/projects/ignitetest35087485/files/. As you will see, it depleted my memory after 5 cycles of load-destroy. Eviction to swap space did not take place and ignite didn't take the offHeapMaxMemory setting into account.

What is the problem here? Any help is much appreciated.

1
How do you destroy the cache? - Valentin Kulichenko
@Valentin I tried these methods: ignite.cache(cache).clear(), ignite.cache(cache).destroy(), ignite.destroyCache(cache). This happens inside a ComputeTask (executed async) where the ignite instance is an autowired IgniteInstanceResource. - Akın Özer
Are you eventually running out of memory? Note that it's possible that Java will not free memory immediately, it will happen only during garbage collection process. If your application doesn't fail with out of memory error and you don't experience very long GC pauses, then most likely there is no leak. - Valentin Kulichenko
P.S. I just created a test that creates and destroys caches with data in a loop. It works fine for me, memory is eventually freed by GC. - Valentin Kulichenko
Hi Valentin, could you pleas mention, how did you cleared/removed cache? - Rajashekhar Meesala

1 Answers

0
votes

The only way which worked for me is to call Cache#removeAll + Ignite#destroyCache + Ignite#createCache. With that I was able to create a new cache with a new/updated config and unlocking the outdated off-heap memory before creating the new cache. That allows to shrink and grow the amount of memory as you need. If you know that you have an absolute max. and no need to shrink it, you can just configure the off-heap-max-memory (+ EvictionPolicy and ExpiryPolicy) and the unused space will be re-used (you won't get over off-heap-max-memory, but the cache also won't shrink).