我们正在尝试设置Node.js Socket.io.我们最后的关注是内存使用.我们正在启动我们的简单服务器(代码如下),这个进程的虚拟内存使用量是〜600 mb.
1000 6463 0.0 0.4 635816 19260 pts/1 Sl+ 12:51 0:00 node /home/data/server.js
server.js:
var express = require('express'); var app = express.createServer(),io = require('socket.io').listen(app); app.listen(8000); io.set('flash policy port',8001); io.enable('browser client minification'); // send minified client io.enable('browser client etag'); // apply etag caching logic based on version number io.set('log level',1); io.set('transports',[ 'websocket','flashsocket','htmlfile','xhr-polling','jsonp-polling' ]); io.sockets.on('connection',function (socket) { socket.on('distribute',function (data) { if(typeof data.key == 'undefined' || (typeof data.key != 'undefined' && data.key != 'randomstringforsecurityreason')){ return false; } delete data.key; socket.broadcast.to(data.channel).emit('eat',data); }); socket.on('pukpuk',function(data) { if(typeof data == "string"){ socket.join(data); } else { for(var i in data) { socket.join(data[i]); } } }); });
这是正常的?那么大的虚拟内存使用量?
编辑:
好的,我发现这很正常. http://comments.gmane.org/gmane.comp.lang.javascript.nodejs/17482