Increasing memory usage with socket.io, node.js x64 on windows server 2008 #943

Closed
jrappswe opened this Issue Jul 4, 2012 · 2 comments

Projects

None yet

2 participants

@jrappswe
jrappswe commented Jul 4, 2012

Hello,

we are running the following code in production and after a couple of days (with an average of 400 simultaneous socket connections on each front) node uses over 2.5gb of memory and increasing. Have anybody else had the same problem and does anybody know why?

process.on( 'uncaughtException', function( err ) { console.log( err ); } );
var io = require( 'socket.io' ).listen( 8080 );
function joinChannel( roomId ) {
this.join( roomId );
}
io.sockets.on( 'connection', function( socket ) {
socket.on( 'joinChannel', joinChannel );
} );
io.set( 'log level', 1 );
var http = require( 'http' );
var handlePostData = function( data ) {
var message = JSON.parse( data.toString() );
io.sockets'in'.volatile.emit( 'clientEvent', message );
};
var server = function( req, res ) {
req.addListener( 'data', handlePostData );
};
http.createServer( server ).listen( 1339 );

best regards Joakim

wavded commented Jul 6, 2012

make sure you leave the room you joined when you are done, if not, it caches messages when a user reconnects to give back to them, can get really big!

jrappswe commented Jul 6, 2012

Thanks for the tip, I did actually rewrite the room-handling (not using join at all) before posting, just to make sure it didn't create the leak. My worries right now is that it might either be socket.io that keeps data to old connections (have profiled the socket.io object and couldn't find anything) or even worse, that v8 doesn't release unused memory in windows as it should. Today we installed a CentOS machine to see if it is a node-windows issue, I will post results from that on Monday.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment