天天看點

linux 記憶體優化echo "/30 * * * root /root/satools/freemem.sh" >> /etc/crondtab

linux 記憶體優化:

1>. /proc是一個虛拟檔案系統,我們可以通過對它的讀寫操作作為與kernel實體間進行通信的一種手段。也就是說可以通過修改/proc中的檔案,來對目前kernel的行為做出調整。也就是說我們可以通過調整/proc/sys/vm/drop_caches來釋放記憶體。

2>. 關于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核心會将它最近通路過的檔案頁面緩存在記憶體中一段時間,這個檔案緩存被稱為pagecache。

手動釋放linux記憶體cache和腳本定時釋放:<code>freemem.sh</code>

将腳本添加到crond任務,定時執行。

<a href="http://blog.chinaunix.net/uid-21516619-id-3490954.html">http://blog.chinaunix.net/uid-21516619-id-3490954.html</a> <a href="http://www.linuxde.net/2011/07/402.html">http://www.linuxde.net/2011/07/402.html</a>

繼續閱讀