1// Flags: --max-old-space-size=16 --trace-gc
2'use strict';
3
4// This tests that vm.compileFunction with dynamic import callback does not leak.
5// See https://github.com/nodejs/node/issues/44211
6require('../common');
7const { checkIfCollectable } = require('../common/gc');
8const vm = require('vm');
9
10async function createCompiledFunction() {
11  return vm.compileFunction(`"${Math.random().toString().repeat(512)}"`, [], {
12    async importModuleDynamically() {},
13  });
14}
15
16checkIfCollectable(createCompiledFunction, 2048);
17