xref: /third_party/node/test/es-module/test-vm-contextified-script-leak.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/es-module/
11cb0ef41Sopenharmony_ci// Flags: --max-old-space-size=16 --trace-gc
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This tests that vm.Script with dynamic import callback 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 createContextifyScript() {
111cb0ef41Sopenharmony_ci  // Try to reach the maximum old space size.
121cb0ef41Sopenharmony_ci  return new vm.Script(`"${Math.random().toString().repeat(512)}";`, {
131cb0ef41Sopenharmony_ci    async importModuleDynamically() {},
141cb0ef41Sopenharmony_ci  });
151cb0ef41Sopenharmony_ci}
161cb0ef41Sopenharmony_cicheckIfCollectable(createContextifyScript, 2048, 512);
17

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