關于釋放linux虛擬內存

發表于:2011-05-09來源:不詳作者:領測軟件測試網采編點擊數: 標簽:
原因分析: Linux下頻繁讀取文件后,物理內存會很快耗盡.當程序結束時,內存不會被正常釋放,而是一直作為caching.這是linux為了提高磁盤的讀取效率而做的設計. 解決方法: 1. linux-sudv:~ #sync sync命令以確保文件系統的完整性。它將所有未寫的系統緩沖區寫到

  原因分析:

  Linux下頻繁讀取文件后,物理內存會很快耗盡.當程序結束時,內存不會被正常釋放,而是一直作為caching.這是linux為了提高磁盤的讀取效率而做的設計.

  解決方法:

  1. linux-sudv:~ #sync

  sync命令以確保文件系統的完整性。它將所有未寫的系統緩沖區寫到磁盤中.包括pagecache,dentries and inodes.

  2. linux-sudv:~ #echo 3 > /proc/sys/vm/drop_caches

  將drop_caches的值設為3.(該值默認為0,可修改為1,2,3,詳見資料引用)

  資料引用:

  /proc/sys/vm/drop_caches(since Linux 2.6.16)

  Writing to this file causes the kernel to drop clean caches,

  dentries and inodes from memory, causing that memory to become

  free.

  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. 

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97