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 usage (external) reports a negative value? · Issue #21570 · nodejs/node

Memory usage (external) reports a negative value? #21570

New issue
Copy link
New issue
Copy link
Closed
Closed
Memory usage (external) reports a negative value?#21570
Copy link
Labels
httpsIssues and PRs related to the https subsystem.memoryIssues and PRs related to Node.js memory management or memory footprint.

Description

@bertlea
bertlea
opened on Jun 28, 2018
Issue body actions
  • Version: v10.5.0
  • Platform: Linux PZW2 4.9.35+ doc: add documentation for AtExit hook #1014 Fri Jun 30 14:34:49 BST 2017 armv6l GNU/Linux
  • Subsystem: REPL in Node.js

Running some http server process in node.js in REPL environment (under tmux), the function: process.memoryUsage() function can return a negative value. Is that a bug? The process (server) was run for many days, and I sometimes use process.memoryUsage() to check the values and I found:

> process.memoryUsage()
{ rss: 33452032,
  heapTotal: 9031680,
  heapUsed: 5112064,
  external: -503806 }

The external memory is negative, but it was still postive 2 days ago when I checked. Notes, I run the node.js with flags:

--expose-gc --max-old-space-size=256

This is running on a Raspberry Pi ZERO W.


Reacted by Amio Jin

Activity

  1. vsemozhetbyt
    added
    processIssues and PRs related to the process subsystem.
    memoryIssues and PRs related to Node.js memory management or memory footprint.
    on Jun 28, 2018
  2. bnoordhuis commented on Jun 28, 2018

    @bnoordhuis
    bnoordhuis
    on Jun 28, 2018
    Member
    More actions

    That probably means you're using an add-on (a native module) with a bug in it - it's miscalling v8::Isolate::AdjustAmountOfExternalAllocatedMemory().

    If you can track this down to Node.js core (i.e., exclude add-ons), let me know and I'll reopen.

  3. bnoordhuis
    closed this as completedon Jun 28, 2018
  4. bertlea commented on Jun 28, 2018

    @bertlea
    bertlea
    on Jun 28, 2018
    Author
    More actions

    OK, I will try to remove all external modules and run the basic functions of the server to try. However, I did not observed that issue on the identical server code ran on version 6.x.x and 8.x.x. Anyway, I will try to run a sample cut-down server without any external module.

  5. bertlea commented on Jun 29, 2018

    @bertlea
    bertlea
    on Jun 29, 2018
    Author
    More actions

    @bnoordhuis I track it down that it got the issue in Node.js core. I can replicate the case that I can have negative external memory from "process.memoryUsage()" call. The situation is simple: You keep making an https GET request to get some contents from a server and do a frequenct gc() call (the V8 garbage collection call), then the external memory reported will going down even keep going even the value is negative.

    I think it affects version 10.4.x (may be earlier) to 10.5.0 (latest version) on at least both Windows 64-bit version and the arm v6l version. I suspect it affects all platforms. I found it do not affect v10.1.0 and earlier version. A simple but not very clean code can show the issue:

    Notes: http seems not affected, and also you need to run it with --expose-gc flag.

    const https = require('https');
    function getip() {
        https.get('https://api.ipify.org', (resp) => {
            let data = '';
            resp.on('data', (chunk) => data += chunk);
            resp.on('end', () => console.log(`data: ${data} ext mem: ${process.memoryUsage().external}`));
            resp.on('error', (err) => console.log('error: ' + err.message));
        });
    
        gc();    
    }
    
    if(typeof gc !== 'function') {
        console.log('gc is not enabled, use --expose-gc flag to run.');
        process.exit();
    }
    
    setInterval(getip, 3000); //get ip every 3 seconds
    console.log('test started. expecting out every 3 seconds. Ctr-c to quit.');
    
  6. bertlea commented on Jun 29, 2018

    @bertlea
    bertlea
    on Jun 29, 2018
    Author
    More actions

    Clarification: The issue I tested is at the "client" side that making HTTPS request, not at the server side.

  7. bnoordhuis
    added
    httpsIssues and PRs related to the https subsystem.
    and removed
    processIssues and PRs related to the process subsystem.
    on Jun 29, 2018
  8. bnoordhuis commented on Jun 29, 2018

    @bnoordhuis
    bnoordhuis
    on Jun 29, 2018
    Member
    More actions

    Thanks, reopened and labels updated.

    Reacted by Nikita Skovoroda and bertlea
  9. bnoordhuis
    reopened this on Jun 29, 2018
  10. bertlea commented on Jul 4, 2018

    @bertlea
    bertlea
    on Jul 4, 2018
    Author
    More actions

    Updated the sample code to demo the issue with a simpler code using a public HTTPS service.

  11. bertlea commented on Aug 9, 2018

    @bertlea
    bertlea
    on Aug 9, 2018
    Author
    More actions

    @bnoordhuis Just curious if this is not yet classified as a bug so nobody is looking at it? Or it is low priority and just waiting in some queues? I am not familiar with the process here, but I agree it is not high-priority as it seems not breaking anything other than reporting negative memory sizes.

  12. logidelic commented on Aug 29, 2018

    @logidelic
    logidelic
    on Aug 29, 2018
    More actions

    FWIW, I've been seeing this on Node 10.9 as well.

  13. mafintosh commented on Aug 30, 2018

    @mafintosh
    mafintosh
    on Aug 30, 2018
    Member
    More actions

    Yea I've hit this multiple times as well. Made a fix here, #22594

  14. Trott commented on Nov 29, 2018

    @Trott
    Trott
    on Nov 29, 2018
    Member
    More actions

    Presumably fixed in 1287e52 which first appeared in Node.js 11.0.0. Please comment (or re-open if GitHub lets you) if you are experiencing this bug with a version of Node.js that is 11.x or newer.

  15. Trott
    closed this as completedon Nov 29, 2018
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

    httpsIssues and PRs related to the https subsystem.memoryIssues and PRs related to Node.js memory management or memory footprint.

    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.