0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-shadow-realm-gc-module.js
Joyee Cheung c5eb2c4190
test: give more time to GC in test-shadow-realm-gc-*
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.

PR-URL: https://github.com/nodejs/node/pull/50735
Refs: https://github.com/nodejs/node/issues/50726
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-11-17 16:09:30 +01:00

19 lines
537 B
JavaScript

// Flags: --experimental-shadow-realm --max-old-space-size=20
'use strict';
/**
* Verifying modules imported by ShadowRealm instances can be correctly
* garbage collected.
*/
const common = require('../common');
const fixtures = require('../common/fixtures');
const { runAndBreathe } = require('../common/gc');
const mod = fixtures.fileURL('es-module-shadow-realm', 'state-counter.mjs');
runAndBreathe(async () => {
const realm = new ShadowRealm();
await realm.importValue(mod, 'getCounter');
}, 100).then(common.mustCall());