problem description
for node applications built with egg, Node serves as an intermediate server, providing server rendering and requesting data from the server. After deployment to the server, memory growth occurs continuously, which is suspected to be a memory leak.
the environmental background of the problems and what methods you have tried
removed related timer, not resolved;
use alinode to monitor the heap snapshot taken, as shown below:
getAllFrontCateInfo
stringjsonnode:
is still dominated by. _ pendingList Array and Request. Ask whether it is caused by the request queue, and if so, how to solve it
related codes
// [natty-fetch](https://github.com/jias/natty-fetch)
/**
* @description ()
* @param {Object} param { timestamp: string }
* @return {Object} result 010206
*/
async getAllFrontCateInfo(param) {
try {
const resp = await fetch.mtop.cat.getAllFrontCateInfo(param);
return resp;
} catch (error) {
this.ctx.logger.error(error);
this.ctx.redirect("/error");
}
}
// controller
// tsp: ,
let tsp = "0";
let allFrontCateInfo = [];
class HomeController extends Controller {
async index() {
const { ctx, config } = this;
const timestamp = String(new Date().getTime());
const preTimestamp = String(new Date().getTime());
let data = await Promise.all([
ctx.service.home.getAllFrontCateInfo({ data: { timestamp: tsp } }),
ctx.service.home.***1(),
ctx.service.home.***2(),
ctx.service.home.***3(),
ctx.service.home.***4(),
]);
if (data[0]) {
tsp = data[0].timestamp || 0;
allFrontCateInfo = data[0].parentCates.slice(0, 11) || [];
}
ctx.body = await ctx.renderView("home", {
pageletProps: {
home: {
allFrontCateInfo,
...
},
},
});
data[0] = null;
data = null;
}
}