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 — Memory leak in setInterval + console.log + process.memoryUsage · Issue #2073 · nodejs/node

Memory leak in setInterval + console.log + process.memoryUsage #2073

New issue
Copy link
New issue
Copy link
Closed
Closed
Memory leak in setInterval + console.log + process.memoryUsage#2073
Copy link

Description

@EricTheOne
EricTheOne
opened on Jun 29, 2015
Issue body actions

The following code exhibits a growth in RSS and heap over time:

setInterval(function doLog() {
    console.log(process.memoryUsage());
}, 100);

leak1

Attached image made by excel - extract measurements from above script to clipboard then:

pbpaste | grep heapTotal | cut -d " " -f 3,5,7 | pbcopy 

Why is this happening?

Activity

  1. JacksonTian commented on Jun 29, 2015

    @JacksonTian
    JacksonTian
    on Jun 29, 2015
    Contributor
    More actions

    process.stdout.write buffered a lot data. Not really memory leak. You can write the data into file instead of.

  2. bnoordhuis commented on Jun 29, 2015

    @bnoordhuis
    bnoordhuis
    on Jun 29, 2015
    Member
    More actions

    It's not necessarily indicative of a memory leak. What happens when you restrict the heap size with --max_old_space_size=32?

  3. EricTheOne commented on Jun 29, 2015

    @EricTheOne
    EricTheOne
    on Jun 29, 2015
    Author
    More actions

    @JacksonTian since I see the measurements as they come on the console, doesn't it mean the buffer gets periodically flushed?

    @bnoordhuis checking

  4. Fishrock123 commented on Jun 29, 2015

    @Fishrock123
    Fishrock123
    on Jun 29, 2015
    Contributor
    More actions

    The following code exhibits a growth in RSS and heap over time:

    The graphs look normal for v8 I think. v8 like to keep as much as it can (within a specified limit, default 1gb iirc) so it doesn't have to re-allocate, is my understanding.

  5. trevnorris commented on Jun 29, 2015

    @trevnorris
    trevnorris
    on Jun 29, 2015
    Contributor
    More actions

    1.5GB for x64 machines, but @Fishrock123 is correct. V8 feels free to use the heap it's given as freely as it wants. My experience is you can only know it's a memory leak for sure if it can cause the process to crash.

  6. EricTheOne commented on Jun 30, 2015

    @EricTheOne
    EricTheOne
    on Jun 30, 2015
    Author
    More actions

    @bnoordhuis running with --max_old_space_size=32:

    1. RSS - not growing (even a small decline over time)
    2. heapTotal - stable
    3. heapUsed - slowly increasing over time and over multiple GC runs.

    @trevnorris's comment means that looking at the growth in heap utilization is not enough, so I guess this behavior is normal.

  7. Fishrock123 commented on Jun 30, 2015

    @Fishrock123
    Fishrock123
    on Jun 30, 2015
    Contributor
    More actions

    Yeah, seems normal, that's just how newer v8 does things. Closing.

  8. Fishrock123
    closed this as completedon Jun 30, 2015
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — 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.