Skip to content

Os.freemem() under Linux #27493

Description

@morgan-wild

Version: 10.15.3 (LTS)
Platform: Linux (Ubuntu server 18.10)
Subsystem: Os.freemem()
Under Linux, Os.freemem() returns the used memory instead of the free one.

os freemem

Activity

  1. bnoordhuis commented on Apr 30, 2019

    @bnoordhuis
    Member

    Similar to #27386?

    Node.js pulls its information straight from the OS by means of the sysinfo(2) system call. If you see the wrong numbers, you've found a kernel bug.

    What does cat /proc/meminfo print?

  2. morgan-wild commented on Apr 30, 2019

    @morgan-wild
    Author

    Thank you for your fast answer!

    As asked :

    Sans titre 2

  3. added
    osIssues and PRs related to the os subsystem.
    memoryIssues and PRs related to Node.js memory management or memory footprint.
    on Apr 30, 2019
  4. bnoordhuis commented on May 1, 2019

    @bnoordhuis
    Member

    Okay, I think I have an inkling of the cause.

    Can you post the output of uname -a, node -p process.arch and the contents of the memory.limit_in_bytes and memory.soft_limit_in_bytes files in /sys/fs/cgroup/memory? Thanks!

  5. morgan-wild commented on May 2, 2019

    @morgan-wild
    Author

    Fore sure, thanks for your help!

    Sans titre 2

  6. morgan-wild commented on May 2, 2019

    @morgan-wild
    Author

    I tried the same thing on another distro (Fedora instead of Ubuntu Server) and it works normally.

    Ubuntu is in cause.

    Sans titre 2

  7. bnoordhuis commented on May 6, 2019

    @bnoordhuis
    Member

    My inkling was that this might have been a 32-to-64-bit (or vice versa) kernel compatibility issue but if both kernel and binary are 64 bits, that can't be it. It's probably still a kernel bug, just not that one. :-)

    On the bright side, Node.js will start preferring /proc/meminfo over sysinfo(2) in the near future (libuv/libuv#2258) so this issue should cease to exist before too long.

  8. morgan-wild commented on May 6, 2019

    @morgan-wild
    Author

    Thank you for your anwser.
    I will wait to try again with the future versions of nodejs.

  9. added a commit that references this issue on May 22, 2019
  10. justb commented on Aug 22, 2022

    @justb

    Any update on this? Still happened at Node.js v16

  11. bnoordhuis commented on Aug 22, 2022

    @bnoordhuis
    Member

    @justb That probably means you don't have /proc mounted or /proc/meminfo doesn't have the expected format.

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.osIssues and PRs related to the os subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions