Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.
Why is swap memory used?
Swap is used to give processes room, even when the physical RAM of the system is already used up. In a normal system configuration, when a system faces memory pressure, swap is used, and later when the memory pressure disappears and the system returns to normal operation, swap is no longer used.
Why does Linux need swap?
Think of a swap partition as overflow space. When the main memory is full, the overflow space can be used for additional memory. ... You can create a swap partition that is used by Linux to store idle processes when the physical RAM is low. The swap partition is disk space set aside on a hard drive.