Linux 101 : Memory load - the "top" command, free memory and cached files -

The "top" command is a Linux comman used to monitor the system resources - RAM, CPU, ... -

The above output gives us information about the RAM usage. 

The "Mem" displays the available physical RAM,  the used RAM, the free RAM, and the buffered RAM

The "Swap" line displays the same information about the swap memory usage.

As we can see above, we have 78.6MiB free memory, but this number is not completely correct because of the Linux caching system.

When Linux loads a file into the RAM, it might not remove it when the program that is using it exits.
If there is enough RAM, Linux will cache the file in the RAM so that it could be accessed faster by other programs for example.
If the RAM is needed by active processes, the caching will not happen as much.

So the because of the caching Linux might seem that it is running low on RAM.

To really know how much RAM we have at our disposal, we need to substract the cache from the used RAM.

In case we want to find out which processes are consuming much of the RAM.
We could do that by running the "top" command, then by hitting the capital "M" letter - while top is running -. 

Top will sort out processes by "%MEM" usage:

The processes on the top of the list will have the higher RAM usage.


Leave as a comment: