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

Usable memory estimate is way off in Linux #123

Open
marcosfrm opened this issue Oct 1, 2023 · 0 comments
Open

Usable memory estimate is way off in Linux #123

marcosfrm opened this issue Oct 1, 2023 · 0 comments
Labels

Comments

@marcosfrm
Copy link
Contributor

Once system has enough cached memory, getUsableMemory() is way off.

SystemInfo::instance().getUsableMemory() / 1024 returns:

$ ./a.out
1729184

While:

$ grep '^MemAvailable:' /proc/meminfo
MemAvailable:    2665180 kB

(this machine does not have swap)

MemAvailable was added in kernel 3.14:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773

free show its value in "available" column.

Adding it to the sysinfo structure was attempted, without success:

https://lore.kernel.org/linux-mm/[email protected]/T/

Hence parsing /proc/meminfo is the only choice:

https://bugs.openjdk.org/browse/JDK-8305770
openjdk/jdk@b6bcbc0

For older kernels without MemAvailable, a not so wrong estimate is MemFree + Cached + Buffers - Shmem:

rfjakob/earlyoom#12

but cannot be done only with sysinfo() information, because it lacks cached memory metric.

Using cbang-git b3f10ca.

@jcoffland jcoffland added the bug label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants