Skip to content

vm.SourceTextModule memory leak #59118

@legendecas

Description

@legendecas

The OOM can be reproduced even without link and evaluate:

// Flags: --max-heap-size=16 --experimental-vm-modules
import {SourceTextModule, createContext} from 'vm';

globalThis.iter = 0;
setInterval(() => {
   // Do not capture any variables.
   globalThis.iter++;
   console.log("iterations", globalThis.iter);
   const context = createContext();
   for (let i = 0; i < 100; i++) {
     new SourceTextModule(`
       export default function() { }
     `, {
       identifier: 'foo',
       context,
     });
   }
}, 1);

This crashes after around tens of iterations deterministically.

Originally posted by @legendecas in #50113

Metadata

Metadata

Assignees

No one assigned

    Labels

    vmIssues and PRs related to the vm subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions