What exactly is the swap partition of a microcomputer?

Overview

Simply put, the Swap partition is a place to temporarily store unused memory content.

The memory size seen in the program is different from the memory size actually stuck on the computer.

By temporarily storing anything in the memory on the hard disk (by using a part of the hard disk as memory), there is a skill that makes the program produce the illusion of a larger memory than actual memory.

For example, the actual memory installed on the computer is 10 GB.

Under normal circumstances, the program that can run at the same time is 10 GB of RAM, right? Programs that use 6 GB of memory and programs that use 4 GB can run simultaneously. The 6 GB program and the 5 GB program cannot be run at the same time. Because it is less than 1 GB.

However, the memory used has the ability to run 6 GB programs and 5 GB programs at the same time.

First, start the program 1 that uses 6 GB of memory. In this way, 6 GB of RAM will be used.

Secondly, in the 6 GB, the less used 1 GB part is placed in the hard disk. In the beginning, I used 6 GB of RAM. Divide it into memory 5 GB and hard disk 1 GB.

Then, the free part of the memory is 5 GB. You can start programs that use 5 GB of memory2.

By the way, what if you want to use the 1 GB of program 1 stored on the hard disk? It must be brought into memory when used. However, the memory is 10 GB, fully used.

In this case, transfer from program 2 to hard disk 1 GB. Program 2 uses 5 GB of memory. Transfer it to memory 4 GB and hard disk 1 GB.

In this way, the memory can have 1 GB of free space.
Transfer the 1 GB used in program 1 to this free part.

Even if the actual memory is 10 GB, you can run programs that use a total of 11 GB of memory. This is already the same as having 11 GB of RAM.

The actual memory is 10 GB. However, the program uses 11 GB of memory. You can say "The memory as seen from the program is 11 GB."

So, in this story, the computer transferred the unused part of the memory to the hard disk.

The place in the hard disk used at this time, that is, the "part of the hard disk used in place of memory" is the "Swap partition".

At last

If the word "Swap partition" appears, please think about it: "This is the place to temporarily store the contents of the memory~".

Guess you like

Origin blog.csdn.net/qq_18191333/article/details/107515543