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?
Checking Memory Usage in Linux using the GUINavigate to Show Applications. Enter System Monitor in the search bar and access the application. Select the Resources tab. A graphical overview of your memory consumption in real time, including historical information is displayed.
Linux free -m Using the free -m command to check your Linux memory usage, displays the values as MB instead of KB. The free column beside -/+ buffers/cache with 823 MB is the actual free memory available to Linux. 1024 MB is the total system memory available, which would be physical RAM.
Linux check memory usage using /proc/meminfo file The /proc/meminfo file stores statistics about memory usage on the Linux based system.
available memory in Linux is, that free memory is not in use and sits there doing nothing. While available memory is used memory that includes but is not limited to caches and buffers, that can be freed without the performance penalty of using swap space.
Since what “available memory” precisely means depends on your purpose, and your purpose is to avoid OOM situations:
Check out how Qt Extended (previously Qtopia) anticipates OOM situations.
There are two events:
/proc/meminfo
)/proc/vmstat
I think)The first is an early warning that memory is low, and triggers more frequent monitoring of pagefaults. The second signals trashing, which kills system performance and is a good hint the OOM killer will run.
At first I found your question easy, as in practice output from free
in the columns '+ buffers/cache' is the one I use and it normally works.
But one of the situations in which it does not work is when you have heavy read to the same blocks. E.g. reading the same 1 gb_file over and over:
while true; do cat 1gb_file >/dev/null; done
If your system has > 1 GB cache then this will run fast. But if you start using some of that cache for something else it will smash the performance of the system.
So when you evaluate your solutions try the above and see if the solution takes that into account.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With