Javascript 这是内存泄漏吗?Node.js把手部件
我在每个快照之前运行垃圾收集器。 当使用ab进行测试时,似乎内存使用量增加了5mb/100个请求,并且在运行GC后不会减少 看起来像是由把手部分引起的泄漏。 你怎么认为?我怎样才能解决这个问题 更新Javascript 这是内存泄漏吗?Node.js把手部件,javascript,express,handlebars.js,Javascript,Express,Handlebars.js,我在每个快照之前运行垃圾收集器。 当使用ab进行测试时,似乎内存使用量增加了5mb/100个请求,并且在运行GC后不会减少 看起来像是由把手部分引起的泄漏。 你怎么认为?我怎样才能解决这个问题 更新 const handlebars = require("express-handlebars"); const cond = require("handlebars-cond").cond; const dateFormat = require("handlebars-dateformat");
const handlebars = require("express-handlebars");
const cond = require("handlebars-cond").cond;
const dateFormat = require("handlebars-dateformat");
app.engine('.hbs', handlebars({ defaultLayout: null, extname: '.hbs', helpers: { cond, dateFormat } })).set("view engine", "hbs");
路由处理程序
我认为问题是由快速车把的依赖性引起的
返回res.send({employees});
//return res.render(“雇员”{employees});
我改变了这一行,重的字符串对象消失了
更新
它实际上是由节点检查器引起的
在1000次请求后,我也进行了验证,内存被成功释放
您应该共享怀疑内存泄漏的代码。否则我们只能猜测;const cond=需要(“把手cond”).cond;const dateFormat=require(“把手日期格式”);app.engine('.hbs',手柄({defaultLayout:null,extname:'.hbs',helpers:{cond,dateFormat}})).set(“查看引擎”,“hbs”)`你能编辑这个问题并把它添加到那里吗?应该比塞进评论更容易阅读。此外,您可能有一些
ab
正在练习的路线。看看这条路线会有什么帮助。
module.exports.allEmployees = (req, res, next) => {
let startTime = new Date();
Employee.findAllAndPopulateImage()
.then(employees =>{
// printEmployees(employees);
playSoundIfVolumeOn(req, "List of employees");
winston.info("Treatment time : " + (new Date() - startTime));
return res.render("employees", { employees });
}).catch(handleError(next));
}