Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM SourceTextModule will not be garbage-collected (memory leak) #41101

Closed
MeemeeLab opened this issue Dec 6, 2021 · 1 comment
Closed

VM SourceTextModule will not be garbage-collected (memory leak) #41101

MeemeeLab opened this issue Dec 6, 2021 · 1 comment

Comments

@MeemeeLab
Copy link

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.

@devsnek
Copy link
Member

devsnek commented Dec 6, 2021

duplicate of #33439

@devsnek devsnek closed this as completed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants