I execute the garbage collector before taking each snapshot. During testing with ab, it appears that the memory usage is increasing by 5mb for every 100 requests and does not decrease even after running the GC.
It seems like there might be a memory leak caused by handlebars partials. What are your thoughts on this? How can I resolve this issue?
Update
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");
the route handler
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));
}