Node memory leak analysis. _ pendingList Array

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:

clipboard.png

getAllFrontCateInfo
stringjsonnode:

clipboard.png

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;
  }

}

it is obvious that the package you are using has its own problem or is not used in this kind of application scenario. (in fact, from the introduction of the project, the reference scenario is very different, how to look at it is a project running in the browser)

  1. _ pendingList there is no length limit, and no success or failure is released, which is why you have so many requests on _ pendingList .
  2. storage is stored on each request of _ pendingList , which is why it is so large.

natty-fetch/blob/master/src/fetch.js-sharpL141
natty-fetch/blob/master/src/request.js-sharpL16


gives too little prompt code, such as where the important _ pendingListArray array is defined and where the push Request object operation code is not available. It is best to add the official customer nail group of alinode: 11794270, which can provide some technical support, or 1012608394995121 under the project invitation

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e53f7d-45253.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e53f7d-45253.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?