Why does Red Hat Linux report less free memory on the system than is actually available?
Solution 1:
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
- Memory can be shared between various processes, through Copy-On-Write memory allocation, memory mapped IO and shared dynamic libraries.
- 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.
Solution 2:
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
Solution 3:
Are you also including the "buffered" and "cached" fields?