自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

簡單介紹Linux內(nèi)存手動釋放方法

運維 系統(tǒng)運維
Linux服務(wù)器內(nèi)存釋放是一件看起來比較有意義但實際上意義不大的工作,但是確實一個學(xué)習(xí)Linux知識的一個很不錯的內(nèi)容。

Linux服務(wù)器內(nèi)存釋放在有些人看起來好像可以提高不少的效率,但是它實際的工作效果并不是很理想,這里我們說一下如何進(jìn)行這份工作,幫助我們更好的去理解Linux系統(tǒng)的工作方式。

大眾釋放內(nèi)存方法

1. 首先使用free -m查看剩余內(nèi)存

view plaincopy to clipboardprint?

linux-8v2i:~ # free -m

total used free shared buffers cached

Mem: 3952 2773 178 0 130 1097

-/+ buffers/cache: 1545 2406

Swap: 2055 0 2055

linux-8v2i:~ # free -m

total used free shared buffers cached

Mem: 3952 2773 178 0 130 1097

-/+ buffers/cache: 1545 2406

Swap: 2055 0 2055

2. 執(zhí)行sync命令

使用sync命令以確保文件系統(tǒng)的完整性,sync 命令運行 sync 子例程,將所有未寫的系統(tǒng)緩沖區(qū)寫到磁盤中,包含已修改的 i-node、已延遲的塊 I/O 和讀寫映射文件。

view plaincopy to clipboardprint?

linux-8v2i:~ # sync

linux-8v2i:~ # sync

3. 修改/proc/sys/vm/drop_caches

view plaincopy to clipboardprint?

echo 3 > /proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/drop_caches

說明:

1>. /proc是一個虛擬文件系統(tǒng),我們可以通過對它的讀寫操作作為與kernel實體間進(jìn)行通信的一種手段。也就是說可以通過修改/proc中的文件,來對當(dāng)前kernel的行為做出調(diào)整。也就是說我們可以通過調(diào)整/proc/sys/vm/drop_caches來釋放內(nèi)存。

2>. 關(guān)于drop_caches的官方說明如下:

Writing to this file causes the kernel to drop clean caches,dentries and inodes from memory, causing that memory to becomefree.

To free pagecache, use echo 1 > /proc/sys/vm/drop_caches;

to free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;

to free pagecache, dentries and inodes, use echo 3 >/proc/sys/vm/drop_caches.

Because this is a non-destructive operation and dirty objects are not freeable, the user should run sync first.

3>. Linux內(nèi)核會將它最近訪問過的文件頁面緩存在內(nèi)存中一段時間,這個文件緩存被稱為pagecache。

 4.再使用free -m查看剩余內(nèi)存,情況如下:

view plaincopy to clipboardprint?

linux-8v2i:~ # free -m

total used free shared buffers cached

Mem: 3952 1773 2325 0 0 80

-/+ buffers/cache: 1545 2406

Swap: 2055 0 2055

linux-8v2i:~ # free -m

total used free shared buffers cached

Mem: 3952 1773 2325 0 0 80

-/+ buffers/cache: 1545 2406

Swap: 2055 0 2055

Linux服務(wù)器內(nèi)存釋放工作也就輕而易舉的完成了。

【編輯推薦】

  1. 詳細(xì)介紹Linux shell腳本基礎(chǔ)學(xué)習(xí)(一)
  2. 簡單介紹Linux進(jìn)程文件路徑的獲取方法
  3. 詳細(xì)介紹Linux shell腳本基礎(chǔ)學(xué)習(xí)(八)
  4. Linux系統(tǒng)安全提高之安全配置
  5. Linux系統(tǒng)安全提高之系統(tǒng)優(yōu)化

 

責(zé)任編輯:小霞 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-01-12 11:52:40

2020-06-22 08:30:42

Linux內(nèi)存手動釋放

2012-09-13 15:37:21

linux內(nèi)存

2020-08-13 11:35:52

Linuxswapbuffer

2010-03-05 13:31:02

Linux進(jìn)程文件路徑

2023-10-18 13:31:00

Linux內(nèi)存

2010-06-09 17:48:15

Linux 編程工具

2010-03-18 16:34:33

Linux命令

2010-06-18 09:51:51

Linux Accep

2009-09-23 10:15:23

Linux curlLinux命令行工具

2009-08-14 17:27:56

C#方法參數(shù)

2010-03-12 10:20:19

Fedora內(nèi)核

2009-08-20 16:25:59

C# 匿名方法

2010-07-29 14:08:05

Flex內(nèi)存泄露

2010-06-21 17:10:02

Linux Arp命令

2010-03-16 11:20:53

Linux 優(yōu)化

2010-03-10 15:05:22

linux系統(tǒng)備份方式

2009-12-23 19:13:40

Fedora Linu

2009-12-29 08:54:09

Ubuntu Linu

2012-07-26 09:10:31

PHP
點贊
收藏

51CTO技術(shù)棧公眾號