busterjs/fs-watch-tree

Possible EventEmitter memory leak

Opened this issue · 5 comments

Anyone else seen this?

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at EventEmitter.addListener (events.js:160:15)
    at /code/sails/node_modules/fs-watch-tree/lib/tree-watcher.js:74:21
    at /code/sails/node_modules/fs-watch-tree/lib/async.js:15:21
    at /code/sails/node_modules/fs-watch-tree/lib/fs-filtered.js:23:9
    at Object.oncomplete (fs.js:93:15)

I hadn't seen that before, but it's not a memory leak. There's just lots of watching going on. I guess the solution is just to up the limit.

@magnars Thanks for the feedback! If you know it offhand, would you mind throwing me a bone as far as the syntax to do this?

I don't know exactly how it works, but according to the error message, you can use emitter.setMaxListeners() to increase the limit.

Found some more info here: http://stackoverflow.com/questions/12151737/node-js-how-to-emitter-setmaxlisteners

More info:
It seems to only be happening on node v0.10.x.
Also, setting process.setMaxListeners(0) doesn't make a difference

Obviously, it's just a warning, so not a huge deal, but we're using this in https://github.com/balderdashy/sails, so I'm trying to kill the warning to avoid scaring new users.

I would wager a guess that you need to set max listeners directly on the complaining EventEmitter.