xref: /third_party/node/test/es-module/test-vm-synthetic-module-leak.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/es-module/
11cb0ef41Sopenharmony_ci// Flags: --experimental-vm-modules --max-old-space-size=16
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This tests that vm.SyntheticModule does not leak.
51cb0ef41Sopenharmony_ci// See https://github.com/nodejs/node/issues/44211
61cb0ef41Sopenharmony_cirequire('../common');
71cb0ef41Sopenharmony_ciconst { checkIfCollectable } = require('../common/gc');
81cb0ef41Sopenharmony_ciconst vm = require('vm');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciasync function createSyntheticModule() {
111cb0ef41Sopenharmony_ci  const m = new vm.SyntheticModule(['bar'], () => {
121cb0ef41Sopenharmony_ci    m.setExport('bar', new Array(512).fill('----'));
131cb0ef41Sopenharmony_ci  });
141cb0ef41Sopenharmony_ci  await m.link(() => {});
151cb0ef41Sopenharmony_ci  await m.evaluate();
161cb0ef41Sopenharmony_ci  return m;
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_cicheckIfCollectable(createSyntheticModule, 4096);
19

Indexes created Thu Nov 07 10:32:03 CST 2024