I' am working on multiplayer game and server side is written with node.js with box2dweb. Server is on aws it's ubuntu 15 LTS (1GB RAM) virtual machine. Game is running fine when i start it within firs couple of hours, but after ~24h game is slowing down even thou no one have been playing during last 22h and last object was spawned 23 h ago. I've tried to use node.js profiler but i have very similar results when i start app and after one day of aplication working. What should i do? What is possible cause of my issue?
I've monitored time usage of functions among 10 min and here are the results :
gamelogic.update() ~40%
b2dWorld.update() ~47%
My profiller code:
var profiler = require('v8-profiler');
var fs = require('fs');
var startProfiling = function(duration){
profiler.startProfiling('1', true);
setTimeout(function(){
var profile1 = profiler.stopProfiling('1');
profile1.export(function(error, result) {
fs.writeFile('./profile.cpuprofile', result);
profile1.delete();
console.log("Profile saved.");
});
},duration);
}
setTimeout(function(){
startProfiling(1000 * 60 * 10);
},1000 * 60 * 60 * 24);
Should I stop listen to socket events on socekt before i delete socket ?
Top results in bash shell: - after 10 min of runnign 10% CPU usage and 8% RAM usage - after 4 days of running 80% CPU usage and 30% RAM usage
While measuring i have the same amount of game objects in the game + one player conected to server.
I have this message from node.js "(node:1324) Warning: Possible EventEmitter memory leak detected. 11 upgradeRequest listeners added. Use emitter.setMaxListeners() to increase limit" does garbage from this stay after deleting socket which called for too many same listener ?