Skip to content

inspector: add tips for Session

When using Session, the object outputed by the console API will not be released.

The example is as follows.

const inspector = require('inspector');

class AAA {
    constructor() {
        const len = 10000000;
        this.memory = new Array(len);
        for (let i = 0; i < len; i++) {
            this.memory[i] = i;
        }
    }
};

const session = new inspector.Session();
// comment out this and test again
session.connect();

const heapUsed = process.memoryUsage().heapUsed;
setInterval(() => {
    const obj = new AAA();
    console.log(obj);
    gc();
    console.log(process.memoryUsage().heapUsed - heapUsed);
}, 100);

node --expose-gc test.js

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading