A computer has sufficient amount of physical memory but most of times we need more so we swap some memory on disk. Swap space is a space on hard disk which is a substitute of physical memory. It is used as virtual memory which contains process memory image. Whenever our computer run short of physical memory it uses it’s virtual memory and stores information in memory on disk. Swap space helps the computer’s operating system in pretending that it have more RAM than it actually has. It is also called as swap file.This interchange of data between virtual memory and real memory is called as swapping and space on disk as “swap space”.
Virtual memory is a combination of RAM and disk space that running processes can use. Swap space is the portion of virtual memory that is on the hard disk, used when RAM is full.
Swap space can be useful to computer in various ways:
- It can be used as a single contiguous memory which reduces i/o operations to read or write a file.
- Applications which are not used or are used less can be kept in swap file.
- Having sufficient swap file helps the system keep some physical memory free all the time.
- The space in physical memory which has been freed due to swap space can be used by OS for some other important tasks.
In operating systems such as Windows, Linux, etc systems provide a certain amount of swap space by default which can be changed by users according to their needs. If you don’t want to use virtual memory you can easily disable it all together but in case if you run out of memory then kernel will kill some of the processes in order to create a sufficient amount of space in physical memory. So it totally depends upon user whether he wants to use swap space or not.
- Operating System | Free space management
- Operating System | Buddy System - Memory allocation technique
- Operating System | Starvation and Aging in Operating Systems
- Operating System | Introduction of Operating System - Set 1
- Operating System | Semaphores in operating system
- Operating System | Requirements of memory management system
- Operating System | Types of Operating Systems
- Operating System | Unix File System
- Operating System | Introduction of System Call
- Operating System | Kernel I/O Subsystem (I/O System)
- Operating System | Thread
- Operating System | Paging
- Operating System | Segmentation
- Functions of Operating System
- Operating System | Multithreading
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.