↑↓ move Enter open Esc close

How to Check RAM Usage in Linux

See how much memory is really available, and which process is eating it.

Almost every "Linux ate my RAM" panic is a misread column. The kernel treats unused memory as wasted memory and fills it with cached file data, released the instant a program needs it. The number that reflects real headroom is "available", and once you read that one instead, most alarms disappear.

Step by step

1 The overall picture

$ free -h

total is the physical RAM, used is what processes hold, buff/cache is the kernel caching files, and available is what could be given to a new program right now. Judge pressure by available.

2 Find the biggest consumers

$ ps aux --sort=-%mem | head -n 10

The ten hungriest processes. RSS is resident memory: actual RAM in use. VSZ counts virtual mappings and overstates reality, so ignore it for this purpose.

3 Watch it live

$ htop

Sort by memory with F6 and watch a suspected leak grow over minutes. top works too if htop is not installed: press M to sort by memory.

4 Check swap activity

$ vmstat 1 5

The si and so columns are swap in and out. Occasional values are fine; sustained non-zero traffic while available is low means genuine memory pressure, and everything will feel slow.

5 Confirm an out-of-memory kill

$ journalctl -k | grep -i "out of memory"

When the kernel runs out, it kills the largest process. If something disappeared without explanation, the evidence is here.

Tips worth knowing

Frequently asked questions

Why is almost none of my RAM free?

The kernel is using it as disk cache, which makes everything faster and is reclaimed instantly when needed. This is correct behaviour, not a problem.

What is the difference between free and available?

free is memory doing absolutely nothing. available is the kernel's estimate of what could be handed to applications, including reclaimable cache. The second is the useful number.

My process was killed with no error: why?

Probably the OOM killer. Check journalctl -k for "Out of memory" and the name of the process it chose.

Should I add swap?

Some swap is worth having as a safety margin, but swap is not a substitute for RAM. If you are swapping continuously, you need more memory or a lighter workload.

The commands behind it

Concepts involved: Process

More how-to guides