You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VM SourceTextModule will not be garbage-collected (memory leak) #41101
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.
importvmfrom'vm';// wait for return key inputawaitnewPromise(resolve=>{process.stdin.once('data',resolve);});letcontext=vm.createContext({
console,test: 'hello'});letbar=newvm.SourceTextModule(`console.log(test);`,{context});awaitbar.link(()=>{});awaitbar.evaluate();bar=null;context=null;eval('%CollectGarbage(true)');// This won't GC vm context and module for unknown reasondebugger;// Check for SourceTextModule in devtool, it's still thereprocess.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.
Activity
devsnek commentedon Dec 6, 2021
duplicate of #33439