Articles‎ > ‎

free -m command in Linux

free -m is the most commonly used command to view memory usage in Linux. Output of free -m will look like this.

===============================================
-bash-3.2# free -m
                    total       used       free     shared    buffers     cached
Mem:           512        503          8          0         17        166
-/+ buffers/cache:       318       193
Swap:          511         95         416
================================================

Interpreting the output of free -m

As we can see, there are three rows Mem, buffers/cache & Swap.

(i) Mem:
  • 512 given under "total" indicates total 512MB of memory available in the server.
  • 503 given under "used" indicates current RAM usage. This number will be a number close to total RAM almost always since Linux will try to utilize spare memory to cache disk data.
  • 8 given under "free" is the amount of free memory available in the system.
  • 0 given under "shared" is the amount of memory shared between processes.
  • 17 given under "buffers" is the memory used for IO buffer.
  • 166 given under "cached" is the memory used for caching disk data.

(ii) buffers/cache
  • 318 given under "used" indicates memory used by running applications
  • 193 given under "free" is the total reclaimable memory. As I said earlier, Linux will try to utilize spare memory to cache disk data. But this memory used for cache can be very easily reclaimed by the OS for applications. Reclaimable memory will be roughly equal to buffers+cached+free, that is 17+166+8

(iii)Swap:
  • 511 given under "total" is total swap memory available in server.
  • 95  given under "used" is total swap memory used
  • 416 given under "free" is free swap memory available in server.

How it is calculated


Physically Used Memory = Actual used memory + buffers + cache = 318+17+166 = 501MB
Physically Free Memory = Total Physical Memory - Actual used memory - buffers - cache = 512-318-17-166 = 11MB
Memory free for Applications = Total Physical Memory - Actual used memory = 512-318 = 194MB
Memory used  by Applications = Physically Used Memory - buffers - cache = 501-17-166 = 318MB
Comments