Quantcast
Channel: VMware Communities: Message List - vSphere Upgrade & Install
Viewing all articles
Browse latest Browse all 11859

Re: What is Swap in and Swap Out

$
0
0

When you load a file or program, the file is stored in the random access memory (RAM). Since RAM is finite, some files cannot fit on it. These files are stored in a special section of the hard drive called the "swap file". swapping is a mechanism in which a process can be swapped temporarily out of memory to a backing store (Swap OUt) and then brought back into memory for continued execution.(Swap In). In other words, when the amount of physical memory (RAM) is full. If the system(say one process) needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space(part of hard disk) & these inactive pages will be brought back for further execution.



bit more detailed:

Suppose there is a situation where a process needs to have one of its virtual page into the physical memory but the physical memory has no room for any more pages to be brought in.

What will happen in this case?

Well, the OS will have to manage this situation by allowing this page to be in physical memory. But for this to happen, a page already residing in physical memory needs to be discarded. Now, if the page to be discarded is from an executable image or data file and the page has not been written to, then it can easily be discarded as whenever required, the same page can easily be brought back into physical memory from the same executable image or data file. But lets suppose the page which the OS is going to discard is the one which has been written to, then this kind of page is known as a dirty page. A dirty page has to be preserved so as to be used at some later stage. When dirty pages are discarded from physical memory then they are saved in a special file known as swap files. This is known as swapping.

Swap cache:

As already discussed above, only dirty pages are swapped as we need to retain the pages that have been modified. Also, suppose if a page was modified and was swapped, now if the same page was brought back into physical memory and now there is a need to swap it again but the page has not been modified any further then there is no need to swap this page. Just discard it as this version of the page is already there in the swap file. This saves a good amount of time which otherwise would have been wasted.

Reference: Linux Memory Management – Swapping, Caches and Shared VM


Viewing all articles
Browse latest Browse all 11859

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>