The role of swap can be simply described as:
When the memory is insufficient, move the data blocks in the memory from the DRAM to the disk space of the swap to free up more space for the current process.
When that data is needed again, you can move the data from the swap disk back to memory, and move the unused blocks of data from memory to the swap.
The act of moving data from memory to the swap is known as a page call, and a page call that occurs in the background has no interference from the application.
The swap space is paged, and each page is the same size as the memory page.
It is not necessary to divide each system into swaps, for example, most embedded systems do not have swaps.
Make sure that the actual remaining memory is larger than the swap memory space, and then perform the following operations, otherwise it will go down!
View the swap partition.
swapon -s will see where your swap partition is.
filename type size used priority
dev/sda2 partition 4095996 85720 -1
Stop the swap partition.
Stopping a swap partition frees the swap memory into the actual memory.
swapoff /dev/sda2
Enable the swap partition.
After the memory of the swap partition is released to the actual memory, enable the swap partition.
swapon -a
Check the swap memory.
After release, the swap usage is 0
free -m