You can quickly check how much memory is being used on your server and how much is available using the free command. Adding the m flag displays values in megabytes so they’re easier to read.
The server in this example has 500MB of total memory and 127MB free. Actual free memory is calculated after subtracting buffers and cache. Linux systems automatically allocate unused memory for OS buffering and caching so it’s important to make sure you’re looking at the value that’s already taken that into account.
Keeping an eye on your server’s memory usage will help you avoid potential performance problems.
When your server runs out of available physical memory it automatically starts using its hard drive to act as additional “virtual memory”. This memory is called swap space.
If your server is consistently requiring more memory than it has available you’ll start seeing decreased performance as accessing swap space on local hard drives is significantly slower than physical RAM. The server in this example has 127MB of free memory and is only using 5MB of allocated swap space so it’s in good shape at the moment!