How-to

Check Memory Usage on a Linux Server

Linux uses spare memory for caching, so "used" looks alarming on a healthy box. The right column and two extra checks tell you whether you really need more RAM.

Which number tells me if memory is short?

The available column of free. It estimates how much memory can be given to programs right now without swapping, counting cache that the kernel can drop:

free -h
#               total        used        free      shared  buff/cache   available
# Mem:           62Gi        21Gi       1.9Gi       1.1Gi        40Gi        40Gi
# Swap:         4.0Gi          0B       4.0Gi

Here only 1.9 GiB is "free", yet 40 GiB is available, because the kernel filled idle RAM with file cache. That is good: reads from cache are far faster than from disk. Worry when available stays low, say under 5 to 10 percent of total, and swap use climbs.

What does /proc/meminfo add?

The detail behind free. A few lines answer most questions:

grep -E '^(MemTotal|MemAvailable|Cached|Dirty|AnonPages|Shmem|Slab|SReclaimable|HugePages_Total|Hugepagesize)' /proc/meminfo
  • AnonPages: memory owned by programs, the part that really grows with load.
  • Cached: file cache, mostly reclaimable.
  • Shmem: shared memory and tmpfs, not freed by dropping cache. PostgreSQL shared buffers show up here.
  • SReclaimable: kernel caches that can be freed under pressure.
  • HugePages_Total: memory reserved for huge pages, invisible to normal programs.

Which processes use the most memory?

ps -eo pid,user,rss,comm --sort=-rss | head -12
top -o %MEM

RSS, the resident set size, is memory a process occupies in RAM right now, in kilobytes for ps. Shared pages count toward every process using them, so adding up RSS overstates the total for PostgreSQL or PHP-FPM pools. smem -tk, from the smem package, reports PSS, which splits shared pages fairly and adds up correctly.

Is the machine under memory pressure?

Ask the kernel directly. Pressure stall information measures how much time tasks spend waiting for memory:

cat /proc/pressure/memory
# some avg10=0.00 avg60=0.00 avg300=0.00 total=0
vmstat 2 5

Non-zero some averages mean tasks are stalling on memory; full values mean everything stalled. In vmstat, watch the si and so columns: steady swap-in and swap-out means the working set does not fit in RAM. Occasional small values are normal.

Did the out-of-memory killer fire?

When memory runs out completely, the kernel kills a process to survive. It logs every kill:

journalctl --dmesg --since '7 days ago' --grep 'oom-kill|Out of memory'
dmesg --ctime --level=err,warn | grep -i 'killed process'

A killed database or Java process with no other error is a classic OOM symptom. Limits in systemd units, such as MemoryMax=, can trigger the same killer for one service, and those kills show up in systemctl status for that unit.

How does memory split on dual-socket machines?

Each processor has its own memory. On a box like M1, with 512 GB DDR4 across two sockets, a process may run low on its local node while the other node has plenty free. Check per node:

numactl --hardware | grep -E 'node [0-9] (size|free)'
numastat -m | head -12

Uneven nodes can cause swapping or slow allocations even when free looks fine. The NUMA and dual-socket servers entry explains the layout and how to bind processes.

When do I actually need more RAM?

SignalMeaning
Available above 20 percent, no swap activityHealthy; cache is doing its job
Available falling over weeksGrowth or a leak; trend it with sar or monitoring
Steady si/so in vmstat, PSI above zeroWorking set exceeds RAM
OOM kills in the kernel logOut of memory; tune limits or add RAM

Steps up the catalog are large: from 64 GB DDR4 on S1 to 128 GB DDR4 on S5, and 512 GB on the High memory line. Since you cannot add RAM to a running machine here, moving to a larger model means ordering it and migrating, so watch the trend early. Swap as a safety net is covered in Swap on Linux.

Memory Steps in the Catalog

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
S1Intel Xeon E-2276G6 / 1264 GB DDR41x 1 TB NVMe2x 10 Gbps$53.32$53.32 (1 month)
S5Intel Xeon E-2276G6 / 12128 GB DDR42x 1 TB NVMe2x 10 Gbps$88.72$88.72 (1 month)
M12x Intel Xeon Gold 5315Y16 / 32512 GB DDR42x 4 TB NVMe2x 25 Gbps$414.70$414.70 (1 month)

Keep Reading

Swap on Linux

What swap is for on a RAM-rich server, how to add a swap file on ext4 or XFS, zram as an alternative and how to tell useful swap from thrashing.

Open

Linux memory management

Virtual memory, pages, overcommit, huge pages, cgroup limits and the OOM killer: how Linux hands out RAM and the knobs worth turning.

Open

NUMA and dual-socket servers

Why two processors in one box share memory unevenly, and when a dual-socket machine beats a single big chip.

Open

High memory servers

512 GB to 1 TB of RAM, from $414.70 a month.

Open

FAQ

Quick Answers

The available column. It counts free memory plus cache the kernel can reclaim.

Linux fills idle RAM with file cache, so look at available, not free.

Run ps -eo pid,rss,comm --sort=-rss or press M in top.

Search the kernel log with journalctl -k for out of memory or oom-kill lines.

Not to a running machine. Order a model with more memory and move the workload when the trend shows you need it.