Hi all,
?When the connection to zookeeper is lost, TreeCache does not free any memory.
Over time it takes all the available memory. Do I have to clean anything up
myself here?
This is the example code (put some data to /foo/bar/baz, some random strings
are enough).
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.ExponentialBackoffRetry;
public class TreeCacheLeak {
public static void main(String[] args) throws Exception {
final CuratorFramework curatorFramework =
CuratorFrameworkFactory.builder()
.connectString("localhost:2181")
.retryPolicy(new ExponentialBackoffRetry(100, 5))
.connectionTimeoutMs(1000)
.sessionTimeoutMs(1000)
.build();
final TreeCache cache;
cache = new TreeCache(curatorFramework, "/foo/bar/baz");
curatorFramework.start();
cache.start();
try {
while (true) {
Thread.sleep(1000);
}
} finally {
cache.close();
}
}
}
and the script to block the connection using iptables:
#!/bin/bash
remove(){
iptables -D INPUT -p tcp --destination-port 2181 -j DROP
iptables -D OUTPUT -p tcp --destination-port 2181 -j DROP
echo "drop"
}
add(){
iptables -A INPUT -p tcp --destination-port 2181 -j DROP
iptables -A OUTPUT -p tcp --destination-port 2181 -j DROP
echo "add"
}
while true; do
add
sleep 5
remove
sleep 5
done
Thanks