Check VPS Memory/RAM Usage

In the course of monitoring your VPS, one of the first things you will want to check is RAM (memory usage). Linux includes a few easy-to-use tools, including free and ps, described here:

The simplest memory reporting tool is free. To use it, simply run:

# free -m

You will see an output like this:

total used free shared buffers cached
Mem: 512 462 49 0 46 127
-/+ buffers/cache: 287 224
Swap: 2047 0 2047

The most important figure to look at is the value under “used” in the “buffers/cache” row. This will tell you how much RAM your processes are currently using, in megabytes. Memory fork errors will occur if the total amount of memory and swap space is lower than this number. To see how much RAM is free, check the “free” column in the “buffers/cache” row.
Another useful tool is ps, which will show you the percent of total RAM used by each running process:

# ps aux

Sample output:

root 1 0.0 0.1 10368 632 ? Ss Jan07 0:00 init [3]
root 2 0.0 0.0 0 0 ? S< Jan07 0:00 [migration/0]
root 3 0.0 0.0 0 0 ? SN Jan07 0:00 [ksoftirqd/0]