Skip to content

Memory leak when using Intl.DateTimeFormat.format() and Intl.NumberFormat.format() #31914

@helloneele

Description

@helloneele
  • Version: v10.18
  • Platform: 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan 9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64
  • Subsystem:

What steps will reproduce the bug?

// leak.js

setInterval(() => {
  var a;
  for (let i = 0; i < 100; i++) {
    a = new Intl.DateTimeFormat("en").format(Date.now());
  }
}, 1);

node --inspect leak.js

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

It always happens. However, it's fixed in node v13.9, but any other version seems to be affected by that bug and leaks memory.

What is the expected behavior?

It shouldn't leak memory.

What do you see instead?

When running the script mentioned above after a few minutes:
image

GC roots no_script_shared_function_infos are not being cleaned up.
image

Additional information

This issue has been fixed in V8 and does not appear to leak memory in Node.js v13.9.
As a temporary workaround, we're memoizing those objects to minimize the leak.

Would it be possible to backport the V8 fix to Node.js v10 and v12 as well? Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    memoryIssues and PRs related to the memory management or memory footprint.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions