Skip to content

v8.serialize leaks memory #40828

Closed
Closed
@JLHwung

Description

@JLHwung

Version

v17.0.1

Platform

21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 arm64

Subsystem

v8

What steps will reproduce the bug?

Run the following snippet

const { serialize } = require("v8");
const { memoryUsage } = process;

for (let i = 0; i < 1 << 22; i++) {
  serialize({});

  if (i % (1 << 15) === 0) {
    console.log(
      `RSS: ${Math.round((memoryUsage().rss / 1024 / 1024) * 100) / 100} MiB`
    );
  }
}

How often does it reproduce? Is there a required condition?

Must reproduce

What is the expected behavior?

The RSS in the stdout should converges to some tens of MiB. For example, if v8.serialize is replaced by JSON.stringify, the RSS is stablized at 33.89MiB.

What do you see instead?

The RSS keeps rising indefinitely.

Additional information

Also affected: v16.0.0

Additional context: babel/babel#13970

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 moduleIssues and PRs related to the "v8" subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions