D
D
deadkrolik2013-05-24 09:06:28
Node.js
deadkrolik, 2013-05-24 09:06:28

Warning for a possible memory leak when running forever-monitor

There is such a thing as forever-monitor - an application for Node.JS that monitors that the process is alive and restarts it if necessary. Works for both nodejs projects and third party programs. The following code (need to keep N workers running all the time):

var forever = require('forever-monitor');
for (var i=1;i<=11;i++) {
  forever.start([ '/usr/bin/php', 'worker.php', i ], {
    max : Math.Infinity,
    silent : false
  });
}


It gives the following warning:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added.
           Use emitter.setMaxListeners() to increase limit.
Trace
    at WriteStream.EventEmitter.addListener(events.js:175:15)
    at Socket.Stream.pipe(stream.js:52:8)
    at startLogs(.../forever-monitor/lib/forever-monitor/plugins/logger.js:65:30)
    at EventEmitter.emit (.../forever-monitor/node_modules/broadway/node_modules/eventemitter2/lib/eventemitter2.js:332:22)
    at Monitor.start.child.on.spinning(.../forever-monitor/lib/forever-monitor/monitor.js:153:10)
    at process.startup.processNextTick.process._tickCallback(node.js:244:9)


I would like to know how critical this is and how it can be avoided.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kxyu, 2013-05-24
@deadkrolik

actually, it's okay - the default EventEmmiter has a limit of 10 listeners, in case objects in the process are subscribed and not unsubscribed (that is, under some conditions this may indicate a leak). Here is such a code. That is, the message is simply displayed, nothing else.

Y
Yuri Shikanov, 2013-05-24
@dizballanze

It's in the official documentation .
In short, this message is issued when you have more than 10 event listeners.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question