piping icon indicating copy to clipboard operation
piping copied to clipboard

possible EventEmitter memory leak detected

Open arman-mukatov opened this issue 8 years ago • 15 comments

I am getting following warning when use version "[email protected]": possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.

downgrade to @0.3.0, and it solves the problem

arman-mukatov avatar Jul 13 '16 11:07 arman-mukatov

I think I have reproduced this, and pushed a fix for a race condition on reloads as 1.0.0-rc.3. If this doesn't fix the issue, can you give me an example?

mdlawson avatar Jul 14 '16 12:07 mdlawson

I see the same error using 1.0.0-rc3 on a CENTOS7 platform. Works fine if I downgrade to 0.3.0. Also works fine on OSX using 1.0.0-rc3.

PitmanPete avatar Sep 09 '16 10:09 PitmanPete

Also having this issue when a large amount of files change (e.g. switching branches). Has taken up all system memory on two occasions. Downgrading to 0.3.0 appears to have fixed.

alex-dixon avatar Sep 15 '16 17:09 alex-dixon

With the new changes in node 6.6.0 to help debug, I've definitely fixed at least one leak (released as 1.0.0-rc.4) related to large numbers of files changing simultaneously. Hope it works this time!

mdlawson avatar Sep 16 '16 12:09 mdlawson

I still got the EventEmitter leak with -rc.4. (I think with lower memory usage, but I can't be 100% sure on that.) I was using node 4.4.0. I upgraded to node 6.6.0, and the leak disappeared. I then downgraded to node 4.5.0 with [email protected], still no leak. So it looks like a problem with something that fixed between node 4.4.0 and 4.5.0!

PitmanPete avatar Sep 19 '16 10:09 PitmanPete

Just encounter this problem today. My issue actually has nothing to do with large number of files changing simultaneously. As soon as I start the app in dev mode, the "memory leak" message will flood in. If I don't kill it quickly, it will quickly eats up all memory + swap and freeze the machine.

Unfortunately following @PitmanPete 's solution doesn't solve the problem. My current environment is Ubuntu 14.04 LTS, node 5.9.0, npm 3.7.3, piping 1.0.0-rc.3. I've tried node 6.6.0, piping 1.0.0-rc.4, node 6.9.4, piping 1.0.0-rc.4. None of them worked.

The only solution to me is to change piping version to ^0.3.0. However, piping 0.3.0 has some performance issues and I'd much prefer to stay with 1.0.0-rc.4.

What's interesting is that this only happens under Ubuntu. There is no problem when running under Windows or OSX.

Just FYI, here is the error message I got (with piping 1.0.0-rc.4):

[1] (node) warning: possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit.
[1] Trace
[1]     at Worker.addListener (events.js:252:17)
[1]     at EventEmitter.<anonymous> (/home/ubuntu/repos/adxfront_temp/node_modules/piping/lib/piping.js:87:12)
[1]     at emitOne (events.js:95:20)
[1]     at EventEmitter.emit (events.js:182:7)
[1]     at online (cluster.js:445:13)
[1]     at Worker.onmessage (cluster.js:431:7)
[1]     at ChildProcess.<anonymous> (cluster.js:737:8)
[1]     at emitTwo (events.js:105:20)
[1]     at ChildProcess.emit (events.js:185:7)
[1]     at handleMessage (internal/child_process.js:718:10)
[1] (node) warning: possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit.
[1] Trace
[1]     at EventEmitter.addListener (events.js:252:17)
[1]     at monitor (/home/ubuntu/repos/adxfront_temp/node_modules/piping/lib/piping.js:65:11)
[1]     at process.<anonymous> (/home/ubuntu/repos/adxfront_temp/node_modules/piping/lib/piping.js:171:11)
[1]     at emitOne (events.js:90:13)
[1]     at process.emit (events.js:182:7)
[1]     at process._fatalException (node.js:264:26)
[1] (node) warning: possible EventEmitter memory leak detected. 11 online listeners added. Use emitter.setMaxListeners() to increase limit.
[1] Trace
[1]     at EventEmitter.addListener (events.js:252:17)
[1]     at monitor (/home/ubuntu/repos/adxfront_temp/node_modules/piping/lib/piping.js:74:11)
[1]     at process.<anonymous> (/home/ubuntu/repos/adxfront_temp/node_modules/piping/lib/piping.js:171:11)
[1]     at emitOne (events.js:90:13)
[1]     at process.emit (events.js:182:7)
[1]     at process._fatalException (node.js:264:26)
[1] (node) warning: possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit.
[1] Trace
[1]     at Worker.addListener (events.js:252:17)
[1]     at EventEmitter.<anonymous> (/home/ubuntu/repos/adxfront_temp/node_modules/piping/lib/piping.js:87:12)
[1]     at emitOne (events.js:95:20)
[1]     at EventEmitter.emit (events.js:182:7)
[1]     at online (cluster.js:445:13)
[1]     at Worker.onmessage (cluster.js:431:7)
[1]     at ChildProcess.<anonymous> (cluster.js:737:8)
[1]     at emitTwo (events.js:105:20)
[1]     at ChildProcess.emit (events.js:185:7)
[1]     at handleMessage (internal/child_process.js:718:10)

 ... ...

realbugger avatar Jan 12 '17 08:01 realbugger

@realbugger I am experiencing this same problem nearly verbatim. I recently updated to Ubuntu 16.10 which may have introduced this problem having recently had no problems until this update.

I do not know which module is being loaded that uses piping since the stack trace is not specific enough and only indicates the piping module as the culprit.

cmuell89 avatar Feb 01 '17 00:02 cmuell89

Same issue here. I'm using Ubuntu at home and Windows 10 at work. I experience this very issue on both operating systems.

zsvoboda avatar Feb 04 '17 10:02 zsvoboda

It happens to me too. I changed the piping to 0.3.2 and the error didn't come out anymore. I am on Ubuntu. Anybody has found the workaround?

Edit: I'm running [email protected] and [email protected]

arfianadam avatar Apr 16 '17 18:04 arfianadam

Any thoughts on this? thanks!

arfianadam avatar Jun 06 '17 04:06 arfianadam

So do I.
This problem also occur in Ubuntu 17.04, nodejs 7.10, piping@^1.0.0-rc.4

linxiaowu66 avatar Jun 20 '17 07:06 linxiaowu66

We have the same problem and downgrading to 0.3.2 resolved it. (1.0.0-rc.4 on Ubuntu 16.04, node 8.9.1)

Are there any plans to try and fix this? I saw that the last update was already 2 years ago...

RobsonAraujo avatar Apr 20 '18 15:04 RobsonAraujo

Realistically I don't have time any more to work on this project, hence its current somewhat sorry state. I'd gladly accept any PR which fixes this issue for people who still find this useful and release as 1.0.0.

mdlawson avatar Apr 23 '18 19:04 mdlawson

We are currently doing tests with pm2 and its watch option. For now it is working fine. At the moment I have no time to look into this, but if there will some spare time in the future I will be more than happy to have a look at this problem. We really like your plugin, thanks for it!

RobsonAraujo avatar Apr 25 '18 18:04 RobsonAraujo

that helped me - https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers

Bonzatina avatar Oct 12 '18 11:10 Bonzatina