Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WatcherManager leaks memory on un-rewatched nodes #31

Closed
jahqueel opened this issue Jan 15, 2015 · 1 comment · May be fixed by YinghanFeng/lordofpomelo#4 or Carolinewly/lordofpomelo#4
Closed

Comments

@jahqueel
Copy link
Contributor

When a watch fires, the WatcherManager keeps the node's path in its re-watch dictionaries instead of clearing it out like the Java client does.

This example will print out the watchManager dictionary after watching and triggering for 100 different nodes:

util = require('util');
zk = require('node-zookeeper-client');

server = process.env.ZOOKEEPER_ADDRESS
testBasePath = '/test';
watchesToLeak = 100;

client = zk.createClient(server);
client.once('connected', function() {
  client.mkdirp(testBasePath, function(err, path) {
    asplode(watchesToLeak);
  });
});
client.connect();

function asplode(i) {
  client.create(testBasePath + '/i-', zk.CreateMode.EPHEMERAL_SEQUENTIAL, function(err, path) {
    client.exists(path, function(ev) {
      console.log(path + " " + ev.getName());
    }, function(err, stat) {
      client.remove(path, function(err) {
        if(i > 0) asplode(i - 1);
        else {
          console.log(util.inspect(client.connectionManager.watcherManager));
          client.close();
        }
      });
    });
  });
}
@jahqueel
Copy link
Contributor Author

The simple fix in #33 is working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant