Once system has enough cached memory, getUsableMemory() is way off.
SystemInfo::instance().getUsableMemory() / 1024 returns:
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/1641483250-18839-1-git-send-email-quic_pintu@quicinc.com/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.
Once system has enough cached memory,
getUsableMemory()is way off.SystemInfo::instance().getUsableMemory() / 1024returns:While:
(this machine does not have swap)
MemAvailablewas added in kernel 3.14:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
freeshow its value in "available" column.Adding it to the sysinfo structure was attempted, without success:
https://lore.kernel.org/linux-mm/1641483250-18839-1-git-send-email-quic_pintu@quicinc.com/T/
Hence parsing
/proc/meminfois 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.