I have read that linux uses free memory for caching, to make system faster. However, both Nagios and Paessler PRTG monitoring system show me that my memory usage is critical.

I could change Nagios mem_usage script to sum free and cached memory, but would that be correct information? I doubt that they misunderstood Linux memory usage.

Lets say I have 8 GB RAM. 5 GB are used, 2 GB is cached, and I have 1 GB of free memory. Real available memory should be free+cached (3 GB)? If some new application would need additional 3 GB RAM, could it take everything from cache and free without using swap, or is there a minimum that should be in cache?

Real example:

$ cat /proc/meminfo
MemTotal:        5984256 kB
MemFree:          137052 kB
Buffers:          140484 kB
Cached:          3439616 kB
SwapCached:          244 kB
Active:          3148824 kB
Inactive:        2341768 kB

My monitoring tools show that I have 137 MB free RAM, however I have ~3,5 GB in Cache.


5 Answers 5


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.

  • thank you. I'm also using this nagios plugin, and this was cause to alerts :)
    – pkoraca
    Jun 6, 2012 at 7:04

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.


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.


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.


Linux uses the available memory for cache and it cleans it whenever it is necessary. You can free the cached memory whenever you want by running

sync; echo 3 > /proc/sys/vm/drop_caches

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.