Configuring Swap Space and Preventing OOM Killer on Linux VPS
Protect Linux systems from Out-Of-Memory (OOM) process termination by provisioning dedicated swapfiles.
На этой странице
Your Own Server (Advanced) руководства
When physical RAM is fully saturated, the Linux kernel invokes OOM Killer to terminate heavy processes (MySQL, Java, Node.js). A swapfile buffers volatile spikes and guarantees crash-resilient uptime.
1. Allocating a 4GB Swapfile#
# 4GB boyutunda swap dosyasi tahsis edin:
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Kalici hale getirmek icin fstab dosyasina ekleyin:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab2. Optimizing Swappiness Tendency#
On high-speed NVMe storage, configure `vm.swappiness = 10` so Linux utilizes physical RAM first before flushing to disk.
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.confКак это сделать?
How this maps to a Clodo service
Hard memory limitYou cannot create swap on a Clodo service; memory is a hard limit set by your plan, and when it is exceeded the kernel kills the process. The job here is not adding swap but finding what exceeds the limit.
Пошагово:
- 1An 'exit code 137' in the console does not mean a crash: the process was killed for exceeding the memory limit.
- 2In Minecraft, cap -Xmx at roughly 75% of the plan's RAM; the rest is JVM overhead. Giving the whole plan to -Xmx is the single most common cause of these kills.
- 3Find what is inflating memory: too many plugins, an oversized view distance, or a leaking mod. The Spark profiler will show you.
- 4If it genuinely is not enough, move to a plan with more RAM from the panel; swap is not a substitute and only makes things slower.
Частые вопросы
Does swap space completely solve insufficient RAM?
No, swap relies on disk storage and is much slower than physical RAM. It serves only as temporary insurance against crashes during brief memory spikes.
Will swap space disappear after restarting the server?
If you do not append the swapfile entry to '/etc/fstab', it will not activate automatically on system boot. Adding it to fstab is required for persistence.
Why should I lower the vm.swappiness value?
The default value may cause the system to swap pages to disk too early. Lowering it to 10 ensures Linux prioritizes physical RAM, reducing unnecessary disk I/O.
Было ли руководство полезным?
Отзыв сразу попадает команде, которая ведёт это руководство.
Не нашли решение?
Вы можете открыть обращение в службу поддержки из панели.

