I've seen that if I press F5 during 15seconds I got a memory leak problem :
(node) warning: possible EventEmitter memory leak detected. 11 change listeners added. Use emitter.setMaxListeners() to increase limit.
Is it possible to avoid that ? I'm using socket.io server side and I set some listeners on connection :
database.on("ready",function(){
//define all the routes
io.on("connection", function(socket){
players.on("change", function change(player) {
socket.emit("/player", player);
});
//other listeners
//I tried :
socket.on("disconnect",function(){
console.log("Disconnected");
players.removeAllListeners("change");
//same thing for other listeners
});
});
});
Even if I remove all the listeners, I'm still getting this memory leak error which means that the app might have troubles with hundreds of clients. If I press F5 like 1 time per second, the "Disconnected" appears. But if I keep pressing F5 I see "Disconnected" message few seconds after. Like there is a delay. Finally, i'm using express.js
What's wrong ?
Thanks in advance