> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Check Memory Usage on Linux (free Command Explained)

> Check memory usage on Linux with free -h. The available column shows the RAM programs can still use; buff/cache is freed on demand. Find the biggest users.

To check memory usage on Linux, run `free -h`. Read the **available** column: it is the kernel's estimate of how much RAM new programs can use without swapping. **buff/cache** is disk cache that Linux frees when programs need it, so low **free** is normal. To see which processes use the most RAM, run `ps -eo pid,user,rss,%mem,comm --sort=-rss | head`.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 5 minutes | Every Linux distribution (`free` is part of procps) | SSH access |

## Before you start

* [Connect with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md). The commands here don't need `sudo`.
* `free` reads `/proc/meminfo`, so it shows what the operating system sees. On a VPS that is the RAM in your plan, minus a little the kernel reserves.

## How to check memory usage with free

```bash theme={null}
free -h
```

```text theme={null}
               total        used        free      shared  buff/cache   available
Mem:           7.8Gi       1.1Gi       3.9Gi        58Mi       3.2Gi       6.8Gi
Swap:          2.0Gi          0B       2.0Gi
```

`-h` prints human-readable units. Use `-m` for mebibytes or `-g` for gibibytes.

## What the free columns mean

| Column | Meaning |
| - | - |
| `total` | Usable RAM (or swap) |
| `used` | Memory in use, calculated as `total - available` |
| `free` | Memory not used for anything, not even cache |
| `shared` | Mostly `tmpfs` (RAM-backed file systems such as `/dev/shm`) |
| `buff/cache` | Kernel buffers and page cache: recently read files kept in RAM to make the next read faster |
| `available` | Estimate of RAM available for new programs without swapping. **This is the number to watch** |

> [!NOTE]
>
> A server with little **free** memory and a large **buff/cache** is healthy. Linux uses spare RAM as cache and gives it back when a program needs it. You only have a memory problem when **available** is low.

## How to watch memory over time

```bash theme={null}
free -h -s 2          # refresh every 2 seconds, Ctrl+C to stop
vmstat 2 5            # 5 samples, 2 seconds apart
```

In `vmstat`, watch `si` and `so` (memory swapped in and out per second). Values above 0 on every line mean the server is short of RAM and using swap, which is much slower than memory.

## How to find which process uses the most memory

```bash theme={null}
ps -eo pid,user,rss,%mem,comm --sort=-rss | head
```

```text theme={null}
  PID USER       RSS %MEM COMMAND
 2038 mysql    105100  1.2 mariadbd
  197 root      98824  1.2 dockerd
 1185 www-data  65012  0.8 php-fpm8.3
```

`RSS` (resident set size) is the physical RAM a process uses, in KiB. Several processes of the same program (PHP-FPM workers, Apache) share some memory, so adding their `RSS` values overstates the total.

For an interactive view, open `htop` and press `M` to sort by memory. See [monitor resources with htop](https://help.freakhosting.com/portals/other/how-to-monitor-server-resources-with-htop.md).

To see memory per service rather than per process:

```bash theme={null}
systemctl status mariadb
```

The `Memory:` line shows what the whole service (all its processes) uses. Replace `mariadb` with your service name.

## How to check swap usage

```bash theme={null}
swapon --show
```

```text theme={null}
NAME      TYPE SIZE USED PRIO
/swapfile file   2G   0B   -2
```

No output means the server has no swap. Swap gives the kernel room to move rarely used memory to disk instead of killing a process, but heavy swap use slows everything down. To add some, see [add swap space](https://help.freakhosting.com/portals/other/how-to-add-swap-space-on-linux.md).

## How to tell if the server ran out of memory

When RAM and swap are both exhausted, the kernel's out-of-memory (OOM) killer ends a process. Check the kernel log:

```bash theme={null}
sudo journalctl -k | grep -i -E "out of memory|oom-kill"
```

A line such as `Out of memory: Killed process 2038 (mariadbd)` names the victim. Fixes are in [fix out of memory killed processes](https://help.freakhosting.com/portals/other/how-to-fix-out-of-memory-killed-processes.md).

## What to do if memory is low

**1. Find the biggest user**

Run the `ps` command above or `htop`, sorted by memory.

**2. Restart or tune it**

A leak often clears after `sudo systemctl restart name`. For databases, PHP-FPM and Java game servers, lower their memory settings (buffer pool, `pm.max_children`, `-Xmx`).

**3. Cap it**

Stop one program taking all the RAM with a `MemoryMax=` limit. See [limit CPU and memory for a process](https://help.freakhosting.com/portals/other/how-to-limit-cpu-and-memory-for-a-process.md).

**4. Add swap or RAM**

Add a swap file as a safety net, or move to a plan with more memory.

> [!WARNING]
>
> You may find advice to run `echo 3 > /proc/sys/vm/drop_caches` to "free memory". It only empties the cache, which the kernel would free anyway when needed, and it makes the server slower until the cache refills. Don't add it to cron.

## Frequently asked questions

### Why is my free memory so low when nothing is running?

Linux fills spare RAM with file cache. Check **available**, not **free**. If **available** is high, you have plenty of memory.

### What is the difference between free and available memory?

**free** is RAM holding nothing at all. **available** adds the cache and other memory the kernel can reclaim, so it shows the real room for new programs.

### Why does my VPS show slightly less RAM than my plan?

The kernel reserves some memory for itself at boot, so `total` is a little lower than the installed RAM. That is normal on every Linux server.

### How do I see memory usage in MB?

Run `free -m`. For gigabytes use `free -g` (rounded down) or `free -h`.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every server guide in one place.

> [card] [Fix out of memory errors](https://help.freakhosting.com/portals/other/how-to-fix-out-of-memory-killed-processes.md)
>
> When the OOM killer strikes.

> [card] [Add swap space](https://help.freakhosting.com/portals/other/how-to-add-swap-space-on-linux.md)
>
> Create a swap file safely.

> [card] [Monitor resources with htop](https://help.freakhosting.com/portals/other/how-to-monitor-server-resources-with-htop.md)
>
> Live view of every process.

> [card] [Limit CPU and memory](https://help.freakhosting.com/portals/other/how-to-limit-cpu-and-memory-for-a-process.md)
>
> systemd MemoryMax and CPUQuota.

> [card] [VPS Panel resource graphs](https://help.freakhosting.com/portals/vps-panel/how-to-monitor-vps-resource-usage.md)
>
> Memory use over time.

***

> [!NOTE]
>
> **Checked against the [free(1)](https://man7.org/linux/man-pages/man1/free.1.html), [ps(1)](https://man7.org/linux/man-pages/man1/ps.1.html) and [vmstat(8)](https://man7.org/linux/man-pages/man8/vmstat.8.html) manuals and the [Linux kernel /proc/sys/vm documentation](https://docs.kernel.org/admin-guide/sysctl/vm.html)** on 4 November 2026; commands tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.