-
Notifications
You must be signed in to change notification settings - Fork 24
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
Memory leak warning when using a predefined instance of rsmq #15
Comments
A simple piece of code to illustrate:
|
Hi, thanks for your hint and the example code, that perfekt ;-) BUT ... i have to disagree. To get rid of the warning you can just set the threshold var RSMQWorker = require( "./" );
var RedisSMQ = require("rsmq");
var WORKERCOUNT = 12;
var rsmq = new RedisSMQ( {host: "127.0.0.1", port: 6379, ns: "rsmq"} );
rsmq.setMaxListeners( WORKERCOUNT );
var workers=[];
for (var i=0; i<WORKERCOUNT; i++) {
var name="worker_"+i.toString();
workers.push(new RSMQWorker(name,{
rsmq: rsmq,
autostart: true,
}))
}
What do you think? |
I think that is "nearly" OK but in my use case it will still cause a memory leak. In my case many workers can be created and deleted over a period of time, and I have no way of knowing how many workers there will be at the time that the One solution might be to |
.....and I use a single |
i optimized the event listener handling so the single rsmq instance will only have as much listeners as workers connected. My small test script can be found here as gist |
OK great - will the listener also be removed on |
Is the fix on NPM? |
Yeah all good - thanks |
If I create an instance of
rsmq
and create 11 or more queues on that instance - if I then create 11 or morersmq-workers
and specify thersmq
instance in the options (so that it does not create its own) then it starts throwing warnings:warning: possible EventEmitter memory leak detected. 11 disconnect listeners added. Use emitter.setMaxListeners() to increase limit.
This is because each time I create the new
rsmq-worker
it adds adisconnect
listener to the originalrsmq
instance. As soon as you add 11 or moreEventEmitter
goes into meltdown :(The text was updated successfully, but these errors were encountered: