Log inSign up

See what runs on your server and how much memory it takes

Run free -h and look at the available column to see real free memory, then ps aux --sort=-%mem | head or top (press M to sort by memory) to find the largest processes. sudo lsof -i :443 tells you which program owns a port, and journalctl -k | grep -i oom shows whether the kernel killed something for lack of memory.

Topic: Server basics · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

How do I read memory with free?

Use free -h and trust the available column, not free. Linux fills unused RAM with file cache because empty memory is wasted; that cache is handed back the moment an application needs it:

free -h
grep -E "MemTotal|MemAvailable|SwapTotal|SwapFree" /proc/meminfo
vmstat 1 5

A small free value with a healthy available value is normal. Pressure starts when available drops near zero and swap usage climbs. In vmstat, steady non-zero values in the si and so columns mean the system is actively swapping, which slows everything down. A modest swap file gives a cushion, but it is not a substitute for enough RAM.

How do I list processes with ps?

ps takes a snapshot, which makes it ideal for scripts and quick sorting:

ps aux --sort=-%mem | head -10
ps aux --sort=-%cpu | head -10
ps -eo pid,user,%cpu,%mem,rss,etime,cmd --sort=-rss | head
ps -fu deploy
pstree -p | less

RSS is the resident memory in kilobytes, the RAM a process really occupies; VSZ includes mapped but unused address space and is rarely useful. etime shows how long each process has run, which helps spot a service that restarts again and again. pgrep -a node finds processes by name with their full command line.

How do I use top and htop?

top is installed everywhere and refreshes every few seconds. Inside it, press M to sort by memory, P for CPU, 1 to show each vCPU, c for full command lines, k to send a signal and q to quit.

Watch the st value in the CPU line. It shows steal time, the share of time your virtual CPU waited for the host. Our plans use shared vCPUs, so a small amount is expected; if it stays high while your own load is low, open a ticket with the numbers. The wa value is time spent waiting for disk.

htop adds colour, mouse support and a tree view. It is in the standard repositories on Ubuntu and Debian and in EPEL on Rocky and Alma:

# Ubuntu and Debian
sudo apt install htop
# Rocky Linux and AlmaLinux
sudo dnf install epel-release && sudo dnf install htop
htop

In htop, F5 toggles the tree, F6 picks the sort column, F9 sends a signal and F4 filters by name. The btop and htop guide covers more live monitors.

How do I stop a runaway process?

Ask politely first with SIGTERM, then force with SIGKILL only if it ignores you:

kill 4321
sleep 5; ps -p 4321
sudo kill -9 4321
pkill -f "python3 worker.py"

SIGTERM lets the program flush buffers and close files; SIGKILL cannot be caught and may leave half-written data. For anything managed by systemd, use sudo systemctl stop name instead, or systemd will simply start it again. To lower the priority of a busy job rather than stop it, use renice +10 -p 4321, and ionice -c3 -p 4321 for disk-heavy work.

How do I find which process uses a file or port?

lsof lists open files, and on Linux network sockets count as files too:

sudo lsof -i :443
sudo lsof -i -P -n | grep LISTEN
sudo lsof /var/log/syslog
sudo lsof -p 4321 | head
sudo lsof +D /mnt/data

The same port question is often faster with sudo ss -tlnp, which needs no extra package. If lsof is missing, install it with sudo apt install lsof or sudo dnf install lsof. A common use is finding why a disk cannot be unmounted or why space did not come back after deleting a file; sudo lsof +L1 lists deleted files still open.

What is the OOM killer and how do I spot it?

When RAM and swap run out, the kernel out-of-memory killer ends the process it scores as the best victim, usually the largest one. Applications disappear without an error of their own, so look in the kernel log:

journalctl -k | grep -iE "out of memory|oom-kill|killed process"
sudo dmesg -T | grep -i oom
systemctl list-units --state=failed

A line such as Out of memory: Killed process 2210 (java) names the victim and its memory use at that moment. If a database or Bitcoin node keeps getting killed, the real fix is to lower its cache settings, add swap as a buffer, or move to a plan with more RAM via move to a larger plan.

How do I protect important services from the OOM killer?

Shift the risk with systemd settings so a less important process dies first, and cap memory hogs so they only hurt themselves:

sudo systemctl edit postgresql
[Service]
OOMScoreAdjust=-500

Values range from -1000 (never kill) to 1000 (kill first). For a worker that sometimes leaks, a hard cap is better:

[Service]
MemoryMax=768M
MemoryHigh=640M

With MemoryHigh the kernel reclaims memory from the service early, and MemoryMax kills only that service when the cap is reached. Watch per-service usage live with systemd-cgtop, and read systemd services for the rest of the unit file.

How do I check load and find a slow server?

Start with the load average, then split the problem into CPU, memory or disk:

uptime
nproc
vmstat 2 5
cat /proc/pressure/memory
cat /proc/pressure/io

A load average around the number of vCPUs from nproc means the server is fully busy; well above it means work is queuing. High wa or io pressure points to disk, high si/so to memory, high us or sy to CPU. Pressure stall files show the percentage of time tasks waited for each resource, a clearer signal than load alone. For history rather than a snapshot, install a monitor such as Netdata.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A2-4room for an app plus a database2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months
A4-8memory-hungry stacks and nodes4 vCPU, 8 GB RAM, 180 GB NVMe$28.80/mo$86.40 for 3 months

Questions about Inspect processes and memory

Why does Linux show almost no free memory?

Unused RAM is used as file cache and released on demand. Look at available in free -h; that is what applications can still get.

What is a zombie process?

A process that has exited but whose parent has not collected its status yet. It uses no memory or CPU. Many zombies point to a bug in the parent; restarting the parent clears them.

Is high steal time a problem?

Some steal time is normal on shared vCPUs. If it stays high for long periods while your own load is light, open a support ticket with the top output.

How much memory does a process really use?

RSS is a good everyday measure. Shared libraries are counted in each process, so adding up RSS overstates the total. smem or /proc/PID/smaps_rollup give a more exact figure.

Should I disable the OOM killer?

No. Without it, an out-of-memory server freezes instead of recovering. Use OOMScoreAdjust and MemoryMax to steer it.