GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — module: fix leak of vm.SyntheticModule · nodejs/node@2e05cf1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • module_wrap.cc
  • test/es-module
    • test-vm-synthetic-module-leak.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/module_wrap.cc‎

Copy file name to clipboardExpand all lines: src/module_wrap.cc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ ModuleWrap::ModuleWrap(Environment* env,
6464
if (!synthetic_evaluation_step->IsUndefined()) {
6565
synthetic_ = true;
6666
}
67+
MakeWeak();
6768
}
6869

6970
ModuleWrap::~ModuleWrap() {
Collapse file

‎test/es-module/test-vm-synthetic-module-leak.js‎

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Flags: --experimental-vm-modules --max-old-space-size=16
2+
'use strict';
3+
4+
// This tests that vm.SyntheticModule does not leak.
5+
// See https://github.com/nodejs/node/issues/44211
6+
require('../common');
7+
const vm = require('vm');
8+
9+
let count = 0;
10+
async function createModule() {
11+
// Try to reach the maximum old space size.
12+
const m = new vm.SyntheticModule(['bar'], () => {
13+
m.setExport('bar', new Array(512).fill('----'));
14+
});
15+
await m.link(() => {});
16+
await m.evaluate();
17+
if (count++ < 4 * 1024) {
18+
setTimeout(createModule, 1);
19+
}
20+
return m;
21+
}
22+
23+
createModule();

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.