Memory Information
Is the server out of memory? Is something leaking? Let's learn to check.
free - Memory Overview
-h for human-readable sizes.
Understanding the Output
| Column | Meaning |
|---|---|
| total | Total physical RAM |
| used | RAM in use by applications |
| free | Completely unused RAM |
| shared | Shared memory |
| buff/cache | Memory used for caching |
| available | Memory available for new apps |
free vs available - The Most Confusing Part
Low free doesn't mean trouble. Linux uses "free" RAM for caching to speed things up.
The available column is what matters - it's free + cache that can be reclaimed.
Think of it this way:
free= money in your walletbuff/cache= money in a jar you can easily break openavailable= total money you can spend right now
The Cache Misconception
"Only 1GB free!" - Don't panic. 5GB is available because the cache can be reclaimed.
Linux caches disk reads in unused RAM. When an app needs memory, the cache shrinks. This is efficient, not a problem.
Swap
Swap is disk space used when RAM is full:
- Swap usage = 0: Normal, RAM isn't exhausted
- Swap usage > 0: RAM pressure, might be slow
- Swap full: Bad - system will be very slow or crash
Swap Usage
High swap usage means your system ran out of RAM. Performance degrades significantly. Either add RAM or reduce memory usage.
/proc/meminfo
For detailed stats:
Per-Process Memory
Or use top/htop and press M to sort by memory.
RSS vs VSZ
| Metric | Meaning |
|---|---|
| RSS | Resident Set Size - actual RAM used |
| VSZ | Virtual Size - total address space |
RSS is the "real" memory usage.
Quick Check Script
echo "=== Memory Usage ==="
free -h
echo ""
echo "=== Top Memory Users ==="
ps aux --sort=-%mem | head -5
What does it mean if 'free' memory is low but 'available' memory is high?
Quick Reference
| Command | Shows |
|---|---|
free -h | Memory overview |
free -m | Memory in MB |
cat /proc/meminfo | Detailed stats |
ps aux --sort=-%mem | Processes by memory |
top then M | Real-time, sorted by memory |
Key Takeaways
free -hgives memory overview- Check
available, not justfree - buff/cache is reclaimable - not wasted
- Swap usage > 0 indicates RAM pressure
- RSS shows actual memory used per process
Next: checking CPU information.