分别对iojs 1.8,1.5 node 0.12 测了下, ab 1000次 阿里云512M 都飙81% ,可以确定是内存泄漏吧!如何排查呢。。求大神解答。。谢谢思密达。。。。
还有在pm2 下 ab 25次左右,就挂掉了。。什么原因呢。。
3 回复
var posts = yield postModel.getAll(query,'-istop -updatetime',page, 10),
total = Math.ceil((yield postModel.querycount(query))/10),
categories = yield categoryModel.getAll({}, '-ccount',1,6);
for(var i = 0;i<posts.length;i++){
posts[i].avatar = (yield userModel.get({nickname:posts[i].name},'avatar')).avatar;
posts[i].createtime = formatDate(posts[i].createtime, true);
posts[i].updatetime = formatDate(posts[i].updatetime, true);
posts[i].flag = posts[i]['_id'].toString();
}
这样会导致内存泄漏吧。。。
//index
fusion.getHome = function* (){
var t = this.query.t,
page = parseInt(this.query.p) ? Math.abs(parseInt(this.query.p)) : 1,
query = {status:1};
if(t && 'all'!=t){
switch (t){
case 'top':
query.istop = true;
break;
case 'good':
query.isgood = true;
break;
case 'doc':
query.type = 'doc';
break;
default :
query.theme = t;
}
}
var posts = yield postModel.getAll(query,'-istop -updatetime',page, 10),
total = Math.ceil((yield postModel.querycount(query))/10),
categories = yield categoryModel.getAll({}, '-ccount',1,6);
for(var i = 0;i<posts.length;i++){
posts[i].avatar = (yield userModel.get({nickname:posts[i].name},'avatar')).avatar;
posts[i].createtime = formatDate(posts[i].createtime, true);
posts[i].updatetime = formatDate(posts[i].updatetime, true);
posts[i].flag = posts[i]['_id'].toString();
}
//signed
if(this.session.user){
this.body = yield this.render('index',{
title:'首页',
user:yield userModel.get({email:this.session.user.email}),
posts:posts,
t:t?t:'all',
page:{
total:total,
page:page
},
categories:categories
});
}else{
this.body = yield this.render('index',{
title:'首页',
posts:posts,
t:t?t:'all',
page:{
total:total,
page:page
},
categories:categories
});
}
}
这样一段会有问题吗