Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a relatively small home Red Hat Linux server (about 8 GB RAM). I don't use it for much other than running some home grown apps to keep track of various things. The only real things running on the box are a database and a web server.

I've noticed that when checking system counters using tools like NMON and TOP that the total system free memory is relatively low (on the order of a few hundred MB), while the active memory for the database and web server is still low (only consuming a combined 3 GB). Even when including all other running processes the total consumed memory is less than 4 GB.

Why does Red Hat Linux report less free memory than the total memory minus the sum total of used memory of running processes?

comments disabled on deleted / locked posts

locked by Iain Nov 5 '12 at 13:21

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

5 Answers

up vote 19 down vote accepted

Don't confuse free memory with unused memory. Free memory, in the unix world is a page of physical memory that has no logical data mapped to it. Unused memory does have some data mapped to it, but it is currently not in active use by a running process.

% free -m
             total       used       free     shared    buffers     cached
Mem:           997        942         55          0         71        366
-/+ buffers/cache:        504        492
Swap:         2015        618       1397

Linux (and all Unix OS'es) try to have as little free memory as possibly. Instead they use memory which is not actively mapped to processes in the running OS for things like file cache and buffers for various IO transfer operations.

Something else that may be confusing you is you cannot simply add up the memory in use by all running processes to get a total memory in use figure. If you attempted this you would quickly discover that you applications appear to be using more memory than actually exists on the machine. This is for two reasons

  1. Memory can be shared between various processes, through Copy-On-Write memory allocation, memory mapped IO and shared dynamic libraries.
  2. The operating system is at liberty to promise more memory to the application than it has actually supplied. The theory being that most application writers prefer to ask for large amounts of memory in one go, to avoid overhead, and may not actually use all that memory.

There is a recent article on lwn.net discussing this issue.

A simple explanation is also provided here: linuxatemyram.com –  Series8217 Nov 3 '11 at 20:11
add comment

Linux will actively cache file system accesses into memory to give faster disk access times. It is nothing to worry about.

Running free -m on the box will give you a better idea of where memory is being used.

Below is the output pulled from one of my boxes. Free memory is 147Meg with almost 4G cached for file system access requests.

free -m
             total       used       free     shared    buffers     cached
Mem:          6035       5888        147          0         77       4116
-/+ buffers/cache:       1693       4341
Swap:         4722          0       4722
add comment

Are you also including the "buffered" and "cached" fields?

add comment

With linux, look at Committed_AS in /proc/meminfo, this is the amount of memory (real + swap) that the kernel has actually promised to running processes.

Linux uses memory very efficiently, any blocks not promised to some process is used to cache recently/frequently accessed files. So, it is typical for Linux to use 90% of all available physical memory not long after boot.

Look at what the kernel has committed itself to providing .. and dirty (swap) usage, this gives you a better overall picture.

If you need to adjust this behavior, please update your question :)

This is the standard MO for Linux.. some distros tweak memory management to suit their needs via sysctl. However, what you report is pretty typical amongst all.

add comment

What kind of kernel are you running on the system? A 32-bit kernel will only report around 3.6GB of memory, unless compiled with PAE enabled.

Saying that, if this is a modern version of Redhat Enterprise Linux (or CentOS) - v3 onwards - the default 32-bit kernel will have this enabled.

If you could post the output of the 'free' command detailed above, we will be able to see whether or not this is the problem.

add comment

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