Quick answer: Check real memory pressure with free -h — look at available, not "free" (Linux intentionally fills RAM with cache). If available is truly low, find the consumers with ps aux --sort=-%mem | head, check the kernel log for OOM kills (dmesg | grep -i oom), add swap as a buffer, and fix or right-size the biggest consumer.
Overview
The most common "high RAM" report is a false alarm: cached memory that Linux returns instantly when needed. Real pressure shows up as low available memory, swap thrashing and the OOM killer terminating processes — typically the database. This guide separates the two and fixes the real case.
Before you start
- SSH access.
- Basic idea of what should run on the server (web server, PHP-FPM, MySQL…).
Step-by-step guide
- Assess real pressure:
Healthy:free -havailableis a decent share of total. Trouble: available near zero and swap heavily used. - Find consumers:
ps aux --sort=-%mem | head -10 - Check for OOM killer events:
If MySQL/MariaDB gets killed, it will restart with an empty cache and poor performance — a classic small-VPS symptom.dmesg -T | grep -i -E "oom|killed process" - Add swap as a safety buffer (if none):
Swap prevents hard OOM crashes but is no substitute for RAM — if it's used constantly, you need more memory.fallocate -l 2G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo '/swapfile none swap sw 0 0' >> /etc/fstab - Right-size the big consumers: lower PHP-FPM
pm.max_children, tune MySQLinnodb_buffer_pool_size(typically 50–60% of RAM on a dedicated DB server, much less on a shared box), restart leaking apps on schedule. - Still tight? Upgrade RAM — it's the cheapest fix for a database-backed site that has outgrown its plan.
Common issues
- "RAM 95% used" panic: if
availableis fine, that's cache working as designed — no action needed. - MySQL keeps dying at night? OOM during backups/cron peaks — add swap, lower buffer sizes, or add RAM.
- Memory grows forever? An app leak — schedule a graceful restart (systemd timer) while you debug.
When to contact support
If memory numbers look impossible for the plan or the server behaves oddly after an upgrade, open a support ticket with free -h and ps output.
Frequently asked questions
Is 90%+ RAM usage always a problem?
No — Linux fills RAM with cache by design. Check the "available" column of free -h; trouble is when available is near zero and swap is thrashing.
What is the OOM killer?
A kernel mechanism that terminates the biggest memory consumer when RAM is exhausted — often the database. Its actions are visible in dmesg.
Does swap replace buying more RAM?
No — swap is a crash safety net. If it is used constantly, performance suffers and you need more RAM.
Related articles
- How to troubleshoot high CPU load
- How to check VPS CPU, RAM and disk usage
- How to upgrade VPS resources
- How to install basic server monitoring
Need a hand? Contact Cloud2Y support →
