Skip to content

Instantly share code, notes, and snippets.

@peteruithoven
Created October 16, 2014 14:55
Show Gist options
  • Save peteruithoven/dd432184667591d7d42a to your computer and use it in GitHub Desktop.
Save peteruithoven/dd432184667591d7d42a to your computer and use it in GitHub Desktop.
Monitoring the server using pm2 indicates a memory leak. The memory usage increased and didn't decrease. Not even when stopping broadcaster.js
var io = require('socket.io-client');
var PORT = 6000;
var socket = io.connect('http://localhost:'+PORT,{forceNew:true});
socket.once('connect',function() {
console.log("connected");
setInterval(function() {
console.log("emit image");
for(var i=0;i<100;i++) {
socket.emit('image', {name: "bob"});
}
},100);
});
var http = require('http').Server();
var io = require('socket.io')(http);
var PORT = 6000;
http.listen(PORT, function(){
console.log('server listening on *:' + PORT);
});
var nsp = io.of('/');
nsp.on('connection', onConnection);
function onConnection(socket) {
console.log("new connection");
socket.on('image', onImage);
}
function onImage(data) {
// console.log("on image: ",data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment