2024-03-02 23:11:30 +01:00
|
|
|
// Flags: --max-old-space-size=16
|
2022-11-29 18:58:43 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// This test ensures that diagnostic channel references aren't leaked.
|
|
|
|
|
2023-11-03 22:53:24 +00:00
|
|
|
const common = require('../common');
|
2022-11-29 18:58:43 +08:00
|
|
|
|
2023-11-03 22:53:24 +00:00
|
|
|
const { subscribe, unsubscribe, Channel } = require('diagnostics_channel');
|
|
|
|
const { checkIfCollectableByCounting } = require('../common/gc');
|
2022-11-29 18:58:43 +08:00
|
|
|
|
|
|
|
function noop() {}
|
|
|
|
|
2023-11-03 22:53:24 +00:00
|
|
|
const outer = 64;
|
|
|
|
const inner = 256;
|
|
|
|
checkIfCollectableByCounting((i) => {
|
|
|
|
for (let j = 0; j < inner; j++) {
|
|
|
|
const key = String(i * inner + j);
|
|
|
|
subscribe(key, noop);
|
|
|
|
unsubscribe(key, noop);
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
}, Channel, outer).then(common.mustCall());
|