How to reliably measure available memory in Linux?

Posted by Alex B on Stack Overflow See other posts from Stack Overflow or by Alex B
Published on 2010-06-11T02:01:32Z Indexed on 2010/06/11 2:02 UTC
Read the original article Hit count: 222

Filed under:
|

Linux /proc/meminfo shows a number of memory usage statistics.

MemTotal:      4040732 kB
MemFree:         23160 kB
Buffers:        163340 kB
Cached:        3707080 kB
SwapCached:          0 kB
Active:        1129324 kB
Inactive:      2762912 kB

There is quite a bit of overlap between them. For example, as far as I understand, there can be active page cache (belongs to "cached" and "active") and inactive page cache ("inactive" + "cached").

What I want to do is to measure "free" memory, but in a way that it includes used pages that are likely to be dropped without a significant impact on overall system's performance.

At first, I was inclined to use "free" + "inactive", but Linux's "free" utility uses "free" + "cached" in its "buffer-adjusted" display, so I am curious what a better approach is.

When the kernel runs out of memory, what is the priority of pages to drop and what is the more appropriate metric to measure available memory?

© Stack Overflow or respective owner

Related posts about linux

Related posts about virtual-memory