Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
2.8.0
-
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
Description
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:
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(); } } }
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.