Version
v16.8.0
Platform
Microsoft Windows NT 10.0.22000.0 x64 (Windows 11 x86_64)
Subsystem
VM
What steps will reproduce the bug?
Run reproduce code below with option --experimental-vm-modules --inspect --max-old-space-size=4 --allow-natives-syntax, and connect devtool.
import vm from 'vm';
// wait for return key input
await new Promise(resolve => {
process.stdin.once('data', resolve);
});
let context = vm.createContext({
console, test: 'hello'
});
let bar = new vm.SourceTextModule(`console.log(test);`, {context});
await bar.link(() => {});
await bar.evaluate();
bar = null;
context = null;
eval('%CollectGarbage(true)'); // This won't GC vm context and module for unknown reason
debugger; // Check for SourceTextModule in devtool, it's still there
process.exit(0);
How often does it reproduce? Is there a required condition?
Anytime will result in memory leak.
What is the expected behavior?
SourceTextModule and contextified object will garbage collected.
What do you see instead?
SourceTextModule and contextified object does not garbage collected.
Additional information
Seems contextified object couldn't garbage collected because SourceTextModule has reference to contextified object.
Version
v16.8.0
Platform
Microsoft Windows NT 10.0.22000.0 x64 (Windows 11 x86_64)
Subsystem
VM
What steps will reproduce the bug?
Run reproduce code below with option
--experimental-vm-modules --inspect --max-old-space-size=4 --allow-natives-syntax, and connect devtool.How often does it reproduce? Is there a required condition?
Anytime will result in memory leak.
What is the expected behavior?
SourceTextModuleand contextified object will garbage collected.What do you see instead?
SourceTextModuleand contextified object does not garbage collected.Additional information
Seems contextified object couldn't garbage collected because
SourceTextModulehas reference to contextified object.