The Definition of Swap Memory or Swap Space in Linux
What is Swap Space in Linux?
Swap space in Linux is usually used when the chunk of physical RAM is sufficient. If the system needs more physical memory and turns out to be RAM is full, inactive pages in memory are moved to swap space. While swap space can help machines with a little amount of RAM, it should not see as replacement for more RAM. Swap space is placed in the disk drive, so the access time will be slower than physical memory.
Swap space can be a dedicated partition (which is a recomendation), a swap file, or a combination of swap partition and swap files.
The formula of Swap Space in Linux
Here the following of RAM’s formula:
if M < 2
S = M * 2
S = M +2
M = amount of RAM in GB
S = amount of SWAP in GB
According to the RAM’s formula, if there is a system with 2 GB of physical RAM will have 4 GB swap. Meanwhile if there is a system with 3 GB of physical RAM will have 5 GB swap. But, for the system with huge amount of RAM (more than 32 GB), you can configure by smaller amount of swap partition (around 1x or less than physical RAM).
What is different between virtual memory and swap space?
- Basic differences : virtual memory is an abstraction of main memory. Virtual memory improved the available computer memory by keeping the inactive parts of the content RAMon the hard disk. Whenever the content is needed, it retrieve it back to the RAM. Swap memory or swap space is part of disk drive that is used for virtual memory. Which is the both are used alternately.
Like explained before, virtual memory is an abstraction of main memory and used to cover the information from the real system’s physical memory. Virtual memory creates an deception of an entire address space with zero beginning locations. It is manly preferred its development by reducing space neededs. It is collected of the available RAM and disk space.
Swap memory is commonly called as swap space. Swap space point out to the chunk of the virtual memory composed as a momentary storage location. Swap space is applied when available RAM is not able to comply the needs of the system’s memory. The example is, in Linux memory system, the kernel establish each page in the physical memory or in the swap space. The kernel also manage a table wherein the information concerning the swapped out pages and pages in physical memory is stored. The pages that have not been accessed a long ago are sent to swap space area. The process is specified to as swapping out. If the same page is needed, it is swapped in physical memory by swapping out a different page. So, the swap memory and virtua memory are similiar as swap memory is used for the technique of virtual memory.
Thanks a lot for having time to read on this web. Stay tune on this web to receiving more awesome articles.
(Source: https://stackoverflow.com/questions/4970421/whats-the-difference-between-virtual-memory-and-swap-space; https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s1-swap-what-is.html)