Swap space or Virtual Memory 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 insufficient amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
The size of your swap should generally be equal to twice your computer’s physical RAM for up to 2 GB of physical RAM. The size of your swap should never be less than 32 MB.