Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better memory monitoring #8

Merged
merged 1 commit into from Nov 1, 2021
Merged

Better memory monitoring #8

merged 1 commit into from Nov 1, 2021

Conversation

artmakh
Copy link
Contributor

@artmakh artmakh commented Nov 1, 2021

This PR improves memory monitoring on Linux-based hosts.

Node's os.freemem doesn't represent how much ram is available for processes. It returns what is shown in cat /proc/meminfo MemFree, which is calculated from memory used by different applications + buffers + Linux disk in-memory caching. This means that's it's ok to have MemFree close to 0 on Linux host, because Linux can always unload disk caches and buffers from memory without any harm to running processes. To clarify this, Linux developers added new field in /proc/meminfo called MemAvailable. This filed represent real free memory capacity for applications on host, without including disk caching.

So, if monitoring should answer the question Is it enough free RAM on my host to run an application? it should use MemAvailable parameter. That's why I think it should be better to switch memory monitoring on this parameter, instead of MemFree.

Unfortunately, there is no way to get MemAvailable from node.os, but thankfully systeminformation is already in use, and you can get MemAvailable there.

Also here is a little bit more information about free vs available https://www.linuxatemyram.com/

@olton olton merged commit a7a1f08 into olton:dev Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants