Memory and swap: when it's time for a higher tier
How to distinguish normal memory usage from a shortage, why swap is needed on a small tier, and by what signs to decide to move to a higher plan.
Updated August 23, 2026
“120 MB free out of 2 GB” scares newcomers and means nothing on Linux: the system deliberately uses free memory for file cache, because empty memory is useless. A different column gives the real picture.
Reading free correctly
free -h
# total used free shared buff/cache available
# Mem: 1.9Gi 742Mi 102Mi 18Mi 1.1Gi 1.0Gi
# Swap: 1.0Gi 126Mi 898Mi
Look at available — how much memory an application can get by evicting cache. As long as this value is well above zero, the machine is fine. free in this sense is useless.
Warning signs:
availableis less than 10% oftotal;Swap usedgrows and does not get freed;- in
vmstat 2,si/soare non-zero and constant — the system is continuously paging to disk.
What exactly is eating memory:
ps aux --sort=-%mem | head -10
smem -tk -s uss 2>/dev/null | tail -10
Swap: needed or not
A small swap is useful at any tier: it gives the system space to move pages that haven't been used for a long time and protects against a process dying instantly during a short spike. It is not a replacement for memory — a disk is hundreds of times slower.
Create a 2 GB swap file:
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile && swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
Curb the system's eagerness to swap:
sysctl -w vm.swappiness=10
echo 'vm.swappiness=10' > /etc/sysctl.d/99-swap.conf
Keep in mind that the swap file takes up space on the tier's disk (40 GB on VDS-1), and writing to it consumes disk speed bandwidth, see Disk load.
Leak or not enough memory
The memory graph in the panel /hosting/vds/m/<id> on a weekly scale helps distinguish one from the other:
- Sawtooth — grows to the ceiling, drops when the service restarts, grows again. This is a leak in the application; a higher tier will only postpone the problem.
- A flat plateau at the ceiling from the very start — the working set simply doesn't have enough room.
- A sharp drop — the OOM killer killed the process; see the article Out of memory.
Before changing the plan, take care of the obvious: limit SystemMaxUse for the journal, set reasonable limits for the database (MySQL asks for quite a lot by default), remove unused services (systemctl list-units --type=service --state=running), and reduce the number of workers for PHP-FPM and Gunicorn.
When to upgrade
If after cleanup available stays near zero for weeks, swap is constantly in use, and you need the application as a whole, take a higher tier. Memory increases along the series 2, 4, 8, 16, 24, 32 GB. Upgrades are only upward, with an additional payment for the remaining days; downgrades are not available: the disk does not shrink. For details, see the article Plan upgrade.
Common mistakes
- Disabling swap completely. During a spike, the system will kill the process instead of surviving for a minute.
- Making swap the size of the disk. The machine won't die, but it will crawl for hours, which is worse than a quick crash.
- Looking at
VIRTin htop. The virtual size for JVM, PostgreSQL, and Node is huge and does not reflect consumption. Look atRES.
You need to check memory before an outage, not after. Set up threshold alerts — there is a simple recipe in the article Site downtime alerts.