mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
...which may be more reliable than than checkIfCollectable(). PR-URL: https://github.com/nodejs/node/pull/51512 Refs: https://github.com/nodejs/node/pull/51362 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
25 lines
754 B
JavaScript
25 lines
754 B
JavaScript
// Flags: --expose-internals --experimental-vm-modules --max-old-space-size=16 --trace-gc
|
|
'use strict';
|
|
|
|
// This tests that vm.SourceTextModule() does not leak.
|
|
// See: https://github.com/nodejs/node/issues/33439
|
|
const common = require('../common');
|
|
const { checkIfCollectableByCounting } = require('../common/gc');
|
|
const vm = require('vm');
|
|
|
|
const outer = 32;
|
|
const inner = 128;
|
|
|
|
checkIfCollectableByCounting(async (i) => {
|
|
for (let j = 0; j < inner; j++) {
|
|
// Try to reach the maximum old space size.
|
|
const m = new vm.SourceTextModule(`
|
|
const bar = new Array(512).fill("----");
|
|
export { bar };
|
|
`);
|
|
await m.link(() => {});
|
|
await m.evaluate();
|
|
}
|
|
return inner;
|
|
}, vm.SourceTextModule, outer).then(common.mustCall());
|