Swap Memory is a disk area (a file or partition) used to store the images of processes that do not need to remain in physical memory. This space is commonly referred to as swap, from the English word “exchange.”
https://es.wikipedia.org/wiki/Espacio_de_intercambio
Swap Memory Calculator
Here’s a step-by-step guide to configure swap memory on Ubuntu, Debian, Red Hat, and Rocky Linux:

Step 1: Check Existing Swap Space
Before creating a swap file, check if swap is already enabled:
sudo swapon --show
If no output appears, your system does not have swap enabled.
Step 2: Check Available Disk Space
Ensure you have enough space for the swap file:
df -h
Look for available space in / or another partition.
Step 3: Create a Swap File
Now with the result of Swap Memory Calculator configure the swap size:
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
To make Swap Permanent add this line to /etc/fstab:
/swapfile none swap sw 0 0
(Optional) Adjust Swappiness to reduce swap usage.
Swappiness is a value ranging from 0 to 100. When the value is close to 0, data will not be swapped to disk unless absolutely necessary. Conversely, when the value is closer to 100, more swaps will occur to free up additional space in RAM.
sudo sysctl vm.swappiness=10
Step 3: Text configuration
mount -a
free -h