mirror of
https://github.com/nodejs/node.git
synced 2025-05-04 18:29:54 +00:00

PR-URL: https://github.com/nodejs/node/pull/45633 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
25 lines
514 B
JavaScript
25 lines
514 B
JavaScript
// Flags: --expose-gc
|
|
'use strict';
|
|
|
|
// This test ensures that diagnostic channel references aren't leaked.
|
|
|
|
require('../common');
|
|
const { ok } = require('assert');
|
|
|
|
const { subscribe, unsubscribe } = require('diagnostics_channel');
|
|
|
|
function noop() {}
|
|
|
|
const heapUsedBefore = process.memoryUsage().heapUsed;
|
|
|
|
for (let i = 0; i < 1000; i++) {
|
|
subscribe(String(i), noop);
|
|
unsubscribe(String(i), noop);
|
|
}
|
|
|
|
global.gc();
|
|
|
|
const heapUsedAfter = process.memoryUsage().heapUsed;
|
|
|
|
ok(heapUsedBefore >= heapUsedAfter);
|