Skip to content

Commit 890f03a

Browse files
committed
test: give more time to GC in test-shadow-realm-gc-module
When --node-builtin-modules-path is used, we read and create new strings for builtins in each realm which increases the memory usage. As a result GC may not be able to keep up with the allocation done in the loop in the test. As a workaround, give GC a bit more time by waiting for a timer in the loop.
1 parent 02db7fc commit 890f03a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/parallel/test-shadow-realm-gc-module.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88

99
const common = require('../common');
1010
const fixtures = require('../common/fixtures');
11+
const { promisify } = require('util');
1112

13+
let wait = promisify(setTimeout);
1214
async function main() {
1315
const mod = fixtures.fileURL('es-module-shadow-realm', 'state-counter.mjs');
1416
for (let i = 0; i < 100; i++) {
1517
const realm = new ShadowRealm();
1618
await realm.importValue(mod, 'getCounter');
19+
// Give the GC some breathing room.
20+
await wait(10);
1721
}
1822
}
1923

0 commit comments

Comments
 (0)