Checking system memory with ‘free’ command
When trying to check the amount of system memory available on your system, the output of the ‘free’ command can be misleading and you may end up thinking you have very low RAM available. However, this need not necessarily be the case. For example, take a look at the following output,
user@host:~$ free -m total used free shared buffers cached Mem: 3834 3644 190 0 280 1758 -/+ buffers/cache: 1605 2228 Swap: 4051 56 3995 user@host:~$
This example system has 3834 MB of total RAM, and as per this output, the amount of free space is a mere 190 MB. A lot of the memory has been allocated to the buffers and cache, due to which the available memory is shown as far less than it actually is. The reason for this is, Linux, by default, utilizes the available RAM to speed up disk operations, by assigning it to buffers (for file system metadata) and cache. This in turn, speeds up the the system as frequently accessed disk information is already loaded in the memory, thus avoiding the needed for additional disk I/O.
If in case the memory is required by running applications, Linux automatically frees up the appropriate amount of ‘buffers/cache’ memory and allocates it to the requesting application. So, in essence, the above output implies that out of an available 3834 MB of system memory, 1605 MB is being utilized by your system and 2228 + 190 MB are free for use by other users or applications. If you wish, you can even clear this manually with the following command,
sync && echo 3 > /proc/sys/vm/drop_caches
The first command takes care of pending writes of disk-cache data. The second part instructs the kernel to drop all the data cached so far. However, I wouldn’t recommend doing this since the memory being used is actually helping to speed up your system.