Home » How to Fix Out of Memory (SWAP) Crashes in Linux (CachyOS / Bazzite)
Gaming Tech

How to Fix Out of Memory (SWAP) Crashes in Linux (CachyOS / Bazzite)

✨ Quick Answer

When running demanding titles on modern hardware under high-performance Linux distributions like CachyOS or Bazzite, the system may suddenly close your games or heavy containers without warning. When checking the logs, the culprit is usually the Out Of Memory (OOM) Killer process.

Quick Diagnostics

Cause
RAM and Swap space completely exhausted (OOM Killer)
Solution
Create extra swap file: fallocate -l 4G /swapfile && mkswap /swapfile
Cause
Misconfigured vm.swappiness parameter
Solution
Set balanced swappiness (10-30): sysctl vm.swappiness=20

When running demanding titles on modern hardware under high-performance Linux distributions like CachyOS or Bazzite, the system may suddenly close your games or heavy containers without warning. When checking the logs, the culprit is usually the Out Of Memory (OOM) Killer process.

This happens because the system runs out of physical RAM and, failing to find enough virtual memory (SWAP space) configured on local storage, freezes or kills the application to protect the operating system.

Step-by-Step Solution

Step 1: Comprobar tu estado actual de SWAP

Open your terminal and run the following command to see if you have virtual memory active:

BASH
swapon --show

If no response line appears, your system completely lacks swap memory.

Step 2: Crear un archivo SWAP seguro de 8 Gigabytes

For gaming and editing, an 8GB file allocated on your SSD is ideal for supporting spikes in RAM consumption. Run the following commands in order:

BASH
# 1. Crear el archivo asignando el espacio
sudo fallocate -l 8G /swapfile

# 2. Darle permisos de seguridad correctos
sudo chmod 600 /swapfile

# 3. Formatear el archivo como espacio de intercambio
sudo mkswap /swapfile

# 4. Activar la nueva memoria SWAP
sudo swapon /swapfile

Step 3: Hacer el cambio permanente para cada reinicio

To prevent the configuration from being erased when shutting down the PC, add the file to the system partition table:

  1. 1

    Step 1

    Open the configuration file:
BASH
sudo nano /etc/fstab
  1. Add the following line at the very end:
PLAINTEXT
/swapfile none swap sw 0 0

Save (Ctrl + O, Enter) and exit (Ctrl + X).

Prevention Advice

Recommended security practices:

  • If you use modern systems, look into using zRAM instead of a traditional SWAP file. zRAM compresses data directly in your physical RAM, being up to 10 times faster than reading and writing to a solid-state drive (SSD).
Author • Web Designer & App Creator

Rodolfo Castro

Web designer, app developer, and founder of SoporteCero. Specializing in UI/UX architecture, digital products, and modern web environments. Every tutorial and guide on SoporteCero is thoroughly tested and verified in our technical lab to ensure reliable, up-to-date solutions.