Skip to content

Feature request: Get usable memory from cgroups, etc. #2286

Closed

Description

@kjin

As cgroups (and possibly other kernel-level resource limits) may specify a limit on the amount of memory a process can consume, it would be useful for this library to expose an API like uv_get_usable_memory (in addition to total and free). Node.js would be able to then use this to set a memory limit for V8 isolates (see nodejs/node#27508).

I've put something together for linux/cgroups here. I wanted to get feedback before taking time to flesh it out more. In particular, I think if we introduce this API, that we could iteratively implement it for other OS's besides Linux, and in the meantime just return a very high value as a place holder (cgroups itself uses a value of 0x7FFFFFFFFFFFF000 to represent no memory limit).

Activity

  1. kjin commented on May 1, 2019

    @kjin
    ContributorAuthor
  2. cjihrig commented on May 2, 2019

    @cjihrig
    Contributor

    I'm not opposed to such an API. If we do add it, we might want to label it as experimental for a few releases though.

  3. added a commit that references this issue on Sep 29, 2025
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