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 {
<span class="code-keyword">public</span> <span class="code-keyword">static</span> void main(<span class="code-object">String</span>[] args) <span class="code-keyword">throws</span> 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.
Originally reported by japher, imported from: Severe memory leak in TreeCache when path does not exist
- assignee: dragonsinth
- status: Resolved
- priority: Critical
- resolution: Fixed
- resolved: 2015-07-31T22:21:06+01:00
- imported: 2025-01-21
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:
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.
Originally reported by japher, imported from: Severe memory leak in TreeCache when path does not exist