How to determine a server's memory usage

This article explains how to determine memory usage statistics on a server by using the free command.

Using the free command

To determine memory usage statistics on a server, follow these steps:

  1. Log in to the server using SSH.
  2. At the command prompt, type the following command: free -m
  3. Interpret the free command output. For example, consider the following sample output from a server:
    [email protected]:~# free -m
                 total      used      free    shared   buffers    cached
    Mem:          2003      1340       663         0       149      1015
    -/+ buffers/cache:       172      1830
    Swap:            0         0         0

    You may be tempted to look at the Mem row, scan the used and free columns, and determine that the server is using 1340 MB of RAM, and the amount of free RAM is only 663 MB. However, this is incorrect. In fact, the server is only using 172 MB of RAM, and has 1830 MB of free RAM.

    This is because Linux uses free memory for disk caching to improve performance. This memory, listed in the buffers and cached columns, is available immediately for any application that may need it. Although it is technically being “used” by Linux in the background, for all practical purposes this memory is free and available. So if you add the free memory (663 MB), buffers memory (149 MB), and cached memory (1015 MB) values, you obtain 1827 MB, which is the actual amount of memory available for applications. (The discrepancy between the 1827 MB that we calculated and the 1830 MB shown in the output is due to rounding because we used the -m option. If you run the free command without this option to obtain amounts in bytes, the numbers will add up exactly.)

 

Was this answer helpful?

Related Articles

How to determine high disk usage locations

This article describes how to determine where your account is using the most disk space....

How to disable e-mail notifications from cron jobs

This article demonstrates how to stop receiving e-mail notifications from cron jobs. By default,...

How to manage the inode count

This article defines an inode count, discusses how to calculate it for your account, and how to...

How to monitor resource usage

This article describes how to monitor resource usage using the top and atop commands. Method 1:...

How to use cURL

This article describes how to use the cURL program to transfer files from the command line. When...