Free / Cached / Available memory on Linux

Solution 1:

I had the same experience in Nagios when I used the check_mem.pl plugin. When you define the tress hold for critical, you need to use a capital C instead of a normal c.

Like this:

command[check_mem]=/usr/lib/nagios/plugins/check_mem -w 10 -C 5 -f

Then it takes the cached memory in account and it will not send warnings.

Solution 2:

Freemem is unallocated memory which is immediately available. This gets used when launching programs and normally you will will experience problems if this gets too low. Monitoring to ensure you have a few MB free should be sufficient. I monitor for 1 MB on my 32 MB OpenWrt router, and 10 MB on my Ubuntu severs. I also monitor swap usage as that will decrease as memory load goes up.

When programs start-up they usually don't use all the required memory initially. It is common for the virtual size of a program to be much larger than the resident (in memory) size. The remaining memory can be allocated from disk (code from the program image and libraries it utilizes) and swap (allocated but not used).

You will likely see significant performance issues if the cached memory gets too low. Depending on how swapping is coded and configured, inactive pages are likely to be swapped to make space for your program. This usually results in far less page swapping than you expect.

I would monitoring the cached memory to ensure performance of running programs rather than to ensure memory is available to start huge programs.

Solution 3:

You should have put the entire output of meminfo. The dirty pages are disk backed but they are counted as pagecache and should be flushed to disk based on requirements.

In a nutshell, what you are saying is right. When calculating free memory take account of cache and buffer as well but keep the dirty pages aside from the calculation.

And to ensure you never run out of memory, keep an account on Committed_AS value. Based on that value, you should determine whether to increase RAM or decrease work load.

Solution 4:

You don't seem to have any memory issue. I believe the workload of both systems is same, right. If so, under nearly equivalent circumstances, they will consume same amount of cached memory.

You seem to do fine with the committed_AS part too. In the second system, there is not much cached memory because there is no need. Being a demand based virtual memory management system, Linux works pretty fine with memory. Cached memory is increased as system workload increases.