镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

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!

Activity

  1. Trott commented on Feb 23, 2020

    @Trott
    Member

    This has been fixed in V8 and it's not leaking memory in node v13.9.
    Our current workaround is to memoize those objects to keep the leak to a minimum.

    Can we please get the V8 fix in node v10 and v12 as well? Thank you!

    @nodejs/v8-update @nodejs/lts

  2. Flarna commented on Mar 5, 2020

    @Flarna
    Member

    I was not able to reproduce this with node 10.x but with 12.x. The V8 fix landed cleanly on v12.x branch, see #31939

  3. added a commit that references this issue on Apr 2, 2020
  4. targos commented on Dec 27, 2020

    @targos
    Member

    fix landed in v12.20.0

  5. added
    memoryIssues and PRs related to Node.js memory management or memory footprint.
    v8 engineIssues and PRs related to the V8 dependency.
    on Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    memoryIssues and PRs related to Node.js 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