Skip to content

Question about uv_get_available_memory API #4336

Answered by bnoordhuis
theanarkh asked this question in Q&A
Discussion options

You must be logged in to vote

On general-purpose multitasking operating systems that's fundamentally unknowable. uv_get_available_memory() is an educated guess, useful for diagnostics but not for policy. Reasons why:

  • the system's available resources may have changed by the time the function returns
  • your process may not be able or is not allowed to allocate that much memory
  • your process can allocate way more due to overcommit or (possibly compressed) swap

If you're trying to write software that's robust in low memory situations, then your best best is to disable overcommit and always handle allocation failures, but even that may not always stave off the OOM killer.

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@theanarkh
Comment options

Comment options

You must be logged in to vote
5 replies
@bnoordhuis
Comment options

Answer selected by theanarkh
@theanarkh
Comment options

@theanarkh
Comment options

@bnoordhuis
Comment options

@theanarkh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants