Question & Answer
Question
Where has all my free memory gone?
Cause
The top command shows Mem: .. free as low and vmstat shows inactive memory as high. It looks like those processes are using a lot of memory in the process list of top command.
Answer
This is a result of a common misconception of what the "free memory" reported by top and "inactive memory" reported by vmstat actually represent.
The apparently small amount of "free" memory is a function of the way Linux allocates memory. There is a good review of it here:
http://www.linuxhowtos.org/System/Linux%20Memory%20Management.htm
In summary, inactive memory is memory that was once allocated to a process, and although it is not currently being used, it remains allocated in the event that the same process requires it again. The likelihood is that it will.
However the inactive memory pool is the first pool to be reallocated when other uses for the memory arise.
As such, it's not a good indicator of the actual memory being used. In reality inactive memory is really free memory since it will be available if required.
In contrast, the commands free and meminfo are better tools for assessing the health of your device in terms of memory usage.
meminfo can show the amount of cached memory. This is memory that has been allocated but can be used by any process that requires it, effectively free memory.
Try also using free -t command and look for the line in the output that reads
-/+ buffers/cache:
This line will show the total amount of memory used compared with the amount that is truly free. For example:
free -t
total used free shared buffers
cached
Mem: 14363884 14262744 101140 0 216852
11810724
-/+ buffers/cache: 2235168 12128716
In the output above,
of the 14,363,884 Kb (13.698Gb) installed, 2,235,168 Kb has been used and 12,128,716 (11.567 Gb) remains free.
Was this topic helpful?
Document Information
Modified date:
17 June 2018
UID
swg21644201