xref: /third_party/node/test/es-module/test-vm-source-text-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 --trace-gc
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This tests that vm.SourceTextModule() does not leak.
51cb0ef41Sopenharmony_ci// See: https://github.com/nodejs/node/issues/33439
61cb0ef41Sopenharmony_cirequire('../common');
71cb0ef41Sopenharmony_ciconst { checkIfCollectable } = require('../common/gc');
81cb0ef41Sopenharmony_ciconst vm = require('vm');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciasync function createSourceTextModule() {
111cb0ef41Sopenharmony_ci  // Try to reach the maximum old space size.
121cb0ef41Sopenharmony_ci  const m = new vm.SourceTextModule(`
131cb0ef41Sopenharmony_ci    const bar = new Array(512).fill("----");
141cb0ef41Sopenharmony_ci    export { bar };
151cb0ef41Sopenharmony_ci  `);
161cb0ef41Sopenharmony_ci  await m.link(() => {});
171cb0ef41Sopenharmony_ci  await m.evaluate();
181cb0ef41Sopenharmony_ci  return m;
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_cicheckIfCollectable(createSourceTextModule, 4096, 1024);
22

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