Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
Linux內(nèi)核為了提高讀寫效率與速度,會(huì)將文件在內(nèi)存中進(jìn)行緩存,這部分內(nèi)存就是Cache Memory(緩存內(nèi)存)。即使你的程序運(yùn)行結(jié)束后,Cache Memory也不會(huì)自動(dòng)釋放。這就會(huì)導(dǎo)致你在Linux系統(tǒng)中程序頻繁讀寫文件后,你會(huì)發(fā)現(xiàn)可用物理內(nèi)存變少。當(dāng)系統(tǒng)的物理內(nèi)存不夠用的時(shí)候,就需要將物理內(nèi)存中的一部分空間釋放出來,以供當(dāng)前運(yùn)行的程序使用。那些被釋放的空間可能來自一些很長時(shí)間沒有什么操作的程序,這些被釋放的空間被臨時(shí)保存到Swap空間中,等到那些程序要運(yùn)行時(shí),再從Swap分區(qū)中恢復(fù)保存的數(shù)據(jù)到內(nèi)存中。這樣,系統(tǒng)總是在物理內(nèi)存不夠時(shí),才進(jìn)行Swap交換。
關(guān)于Swap分區(qū),其實(shí)我們有很多疑問,如果能弄清楚這些疑問,那么你對(duì)Swap的了解掌握就差不多了。如何查看Swap分區(qū)大小? Swap分區(qū)大小應(yīng)該如何設(shè)置?系統(tǒng)在什么時(shí)候會(huì)使用Swap分區(qū)? 是否可以調(diào)整? 如何調(diào)整Swap分區(qū)的大小?Swap分區(qū)有什么優(yōu)劣和要注意的地方? Swap分區(qū)是否必要?那么我一個(gè)一個(gè)來看看這些疑問吧!
查看Swap分區(qū)大小
查看Swap分區(qū)的大小以及使用情況,一般使用free命令即可,如下所示,Swap大小為2015M,目前沒有使用Swap分區(qū)
[root@DB-Server ~]# free -m
total used free shared buffers cached
Mem: 1000 855 145 0 28 296
-/+ buffers/cache: 530 470
Swap: 2015 0 2015
分享標(biāo)題:Swap交換分區(qū)概念-創(chuàng)新互聯(lián)
當(dāng)前鏈接:http://www.chinadenli.net/article4/dhcdoe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、軟件開發(fā)、網(wǎng)頁設(shè)計(jì)公司、全網(wǎng)營銷推廣、ChatGPT、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容