curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jordan Zimmerman (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CURATOR-240) Severe memory leak in TreeCache when path does not exist
Date Fri, 31 Jul 2015 20:01:04 GMT

    [ https://issues.apache.org/jira/browse/CURATOR-240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14649743#comment-14649743
] 

Jordan Zimmerman commented on CURATOR-240:
------------------------------------------

Note: in ZK 3.4.x there's no way to clear a watcher once set. Make sure you use the same watcher
instance for the same path and it's supposed to override it.

> Severe memory leak in TreeCache when path does not exist
> --------------------------------------------------------
>
>                 Key: CURATOR-240
>                 URL: https://issues.apache.org/jira/browse/CURATOR-240
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 2.8.0
>         Environment: java version "1.7.0_71"
> Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
> Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
> OSX Yosemite
>            Reporter: Joe Littlejohn
>            Assignee: Scott Blum
>            Priority: Critical
>              Labels: memory-leak
>
> When creating a TreeCache, if the path supplied does not exist in Zookeeper then the
heap is quickly exhausted. The problem appears to be instances of org.apache.curator.framework.imps.NamespaceWatcher.
> Try running the following test:
> {code}
> package org.apache.curator.framework.recipes.cache;
> import org.apache.curator.framework.CuratorFramework;
> import org.apache.curator.framework.CuratorFrameworkFactory;
> import org.apache.curator.framework.recipes.cache.TreeCache;
> import org.apache.curator.retry.RetryOneTime;
> import org.apache.curator.test.TestingServer;
> public class TreeCacheLeak {
>     public static void main(String[] args) throws Exception {
>         TestingServer server = new TestingServer();
>         
>         final CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(server.getConnectString(),
new RetryOneTime(1));
>         curatorFramework.start();
>         final TreeCache cache = new TreeCache(curatorFramework, "/foo/bar/baz");
>         cache.start();
>         try {
>             while (true) {
>                 Thread.sleep(1000);
>             }
>         } finally {
>             cache.close();
>             server.close();
>         }
>     }
> }
> {code}
> Launch the class then connect e.g. jvisualvm. You'll see the heap growing and if you
watch for a few minutes then take a heap dump, you'll see millions of instances of org.apache.curator.framework.imps.NamespaceWatcher
are present.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message