mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
c5eb2c4190
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>
25 lines
651 B
JavaScript
25 lines
651 B
JavaScript
// Flags: --experimental-shadow-realm --max-old-space-size=20
|
|
'use strict';
|
|
|
|
/**
|
|
* Verifying ShadowRealm instances can be correctly garbage collected.
|
|
*/
|
|
|
|
const common = require('../common');
|
|
const { runAndBreathe } = require('../common/gc');
|
|
const assert = require('assert');
|
|
const { isMainThread, Worker } = require('worker_threads');
|
|
|
|
runAndBreathe(() => {
|
|
const realm = new ShadowRealm();
|
|
realm.evaluate('new TextEncoder(); 1;');
|
|
}, 100).then(common.mustCall());
|
|
|
|
// Test it in worker too.
|
|
if (isMainThread) {
|
|
const worker = new Worker(__filename);
|
|
worker.on('exit', common.mustCall((code) => {
|
|
assert.strictEqual(code, 0);
|
|
}));
|
|
}
|