Fix available memory extraction on Linux (dotnet/coreclr#26764)
authorJan Vorlicek <janvorli@microsoft.com>
Tue, 24 Sep 2019 18:00:39 +0000 (20:00 +0200)
committerGitHub <noreply@github.com>
Tue, 24 Sep 2019 18:00:39 +0000 (20:00 +0200)
commitd7fe87132b66fb067fd2d6dd8751850728531881
tree6d3c01ee32bd2f67820cb7322148d78d1a7c02d6
parent2e8dad7f260d68472fe36822f8577741e76de6eb
Fix available memory extraction on Linux (dotnet/coreclr#26764)

* Fix available memory extraction on Linux

The GlobalMemoryStatusEx in PAL is returning number of free physical pages in
the ullAvailPhys member. But there are additional pages that are allocated
as buffers and caches that get released when there is a memory pressure and
thus they are effectively available too.

This change extracts the available memory on Linux from the /proc/meminfo
MemAvailable row, which is reported by the kernel as the most precise
amount of available memory.

Commit migrated from https://github.com/dotnet/coreclr/commit/859f464d867c5529d4fc5ca747751dea06895da4
src/coreclr/src/gc/unix/config.gc.h.in
src/coreclr/src/gc/unix/configure.cmake
src/coreclr/src/gc/unix/gcenv.unix.cpp
src/coreclr/src/pal/src/misc/sysinfo.cpp