You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Zbyszek B (JIRA)" <ji...@apache.org> on 2018/03/07 15:04:00 UTC

[jira] [Issue Comment Deleted] (IGNITE-7319) Memory leak during creating/destroying local cache

     [ https://issues.apache.org/jira/browse/IGNITE-7319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zbyszek B updated IGNITE-7319:
------------------------------
    Comment: was deleted

(was: {code:java}
// code placeholder
{code}
package pack1; import org.apache.ignite.*; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.util.Collections; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicLong; public class Demo \{ private final static Ignite ignite = createIgnite(); private final static AtomicLong localCacheCreateCount = new AtomicLong(); private final static AtomicLong localCacheDestroyCount = new AtomicLong(); private final static BlockingQueue<IgniteCache<String, BinaryObject>> queue = new LinkedBlockingQueue<>(100); public static void main(String[] args) throws Exception { CompletableFuture.runAsync(Demo::runProducer); CompletableFuture.runAsync(Demo::runProducer); CompletableFuture.runAsync(Demo::runConsumer); CompletableFuture.runAsync(Demo::runConsumer); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); do { String input = br.readLine(); if ("q".equals(input)) { System.out.println("Exit!"); System.exit(0); } else \{ System.out.println("Queue size: " + queue.size()); System.out.println("Caches created: " + localCacheCreateCount.longValue()); System.out.println("Caches destroyed: " + localCacheDestroyCount.longValue()); } } while (true); } private static void runProducer() \{ do { try { IgniteCache<String, BinaryObject> cache = createLocalCache(); queue.put(cache); } catch (Exception e) \{ throw new RuntimeException(e); } } while (true); } private static void runConsumer() \{ do { try { IgniteCache<String, BinaryObject> cache = queue.take(); cache.close(); cache.destroy(); localCacheDestroyCount.incrementAndGet(); } catch (Exception e) \{ throw new RuntimeException(e); } } while (true); } private static Ignite createIgnite() \{ IgniteConfiguration iCfg = new IgniteConfiguration(); String workDirectory = System.getProperty("user.home") + File.separator + "ignite"; iCfg.setWorkDirectory(workDirectory); System.out.println(); System.out.println(String.format(">>> Starting Ignite on %s; work directory %s ...", "MyLeakingNode", workDirectory)); System.out.println(); final Ignite ignite = Ignition.start(iCfg); ClusterNode localNode = ignite.cluster().localNode(); System.out.println(); System.out.println(String.format(">>> Ignite started on %s (%s) successfully!", "MyLeakingNode", localNode.id())); System.out.println(); return ignite; } private static IgniteCache<String, BinaryObject> createLocalCache() \{ final String cacheName = "localCache" + localCacheCreateCount.incrementAndGet(); final CacheConfiguration<String, BinaryObject> cCfg = new CacheConfiguration<>(); cCfg.setName(cacheName); cCfg.setStoreKeepBinary(true); cCfg.setCacheMode(CacheMode.LOCAL); cCfg.setOnheapCacheEnabled(false); cCfg.setCopyOnRead(false); cCfg.setBackups(0); cCfg.setWriteBehindEnabled(false); cCfg.setReadThrough(false); cCfg.setReadFromBackup(false); cCfg.setQueryEntities(Collections.singletonList( new QueryEntity(String.class.getTypeName(), "LocalEntity"))); ignite.destroyCache(cacheName); // local cache is not really local - reference can be kept by other nodes if restart during the load happens return ignite.createCache(cCfg).withKeepBinary(); } })

> Memory leak during creating/destroying local cache
> --------------------------------------------------
>
>                 Key: IGNITE-7319
>                 URL: https://issues.apache.org/jira/browse/IGNITE-7319
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 2.3
>            Reporter: Mikhail Cherkasov
>            Assignee: Alexey Goncharuk
>            Priority: Major
>             Fix For: 2.5
>
>
> The following code creates local caches:
> {code}
> private IgniteCache<String, BinaryObject> createLocalCache(String name) { 
>         CacheConfiguration<String, BinaryObject> cCfg = new 
> CacheConfiguration<>(); 
>         cCfg.setName(name); 
>         cCfg.setGroupName("localCaches"); // without group leak is much 
> bigger! 
>         cCfg.setStoreKeepBinary(true); 
>         cCfg.setCacheMode(CacheMode.LOCAL); 
>         cCfg.setOnheapCacheEnabled(false); 
>         cCfg.setCopyOnRead(false); 
>         cCfg.setBackups(0); 
>         cCfg.setWriteBehindEnabled(false); 
>         cCfg.setReadThrough(false); 
>         cCfg.setReadFromBackup(false); 
>         cCfg.setQueryEntities(<some basic query here>); 
>         return ignite.createCache(cCfg).withKeepBinary(); 
>     } 
> {code}
> The caches are placed in the queue and are picked up by the worker thread which just destroys them after removing from the queue. 
> This setup seems to generate a memory leak of about 1GB per day. 
> When looking at heap dump, I see all space is occupied by instances of 
> java.util.concurrent.ConcurrentSkipListMap$Node.
> User list: http://apache-ignite-users.70518.x6.nabble.com/Memory-leak-in-GridCachePartitionExchangeManager-tt18995.html



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)