release cache memory under LinuxCareful friends will notice that when you frequently access files under Linux, physical memory will soon be used up, and when the program is finished, memory will not be released normally, but as a caching. This question seems to be a lot of people asking, But I don't see any good solutions. Then let me talk about this.
At the end of my command, used for 244mb,free for the 4mb,buffers 8mb,cached for 174MB, the days are cached eaten. Don't be nervous, this is to improve the efficiency of the file reading practice.
reference [Url]http://www.2qyou.com/thread-591-1-1.html[/url] to improve disk access efficiency, Linux has done some careful design, in addition to caching dentry (for VFS, Accelerates file path name to Inode conversion), also takes two main cache methods: Buffer cache and Page cache. The former is read and write to disk block, the latter is read and write to the file inode. These cache effectively shorten the time of the I/O system call (such as read,write,getdents). "
So someone said that some time, Linux will automatically release the memory used, we use free to try again to see if there is release?
There is no change in MS, so can I manually release the memory??? The answer is OK!
/proc is a virtual file system that we can use to communicate with kernel entities through its read and write operations. That is, you can make adjustments to the current kernel behavior by modifying the files in/proc. Then we can adjust the/PROC/SYS/VM /drop_caches to free memory. The operation is as follows:
[Root@server test]# Cat/proc/sys/vm/drop_caches
0
First, the/proc/sys/vm/drop_caches value defaults to 0.
[Root@server test]# Sync
Manually perform the sync command (description: The sync command runs the Sync subroutine.) If the system must be stopped, run the sync command to ensure the integrity of the file system. The Sync command writes all of the unused system buffers to disk, including modified I-node, deferred block I/O, and read-write mapping files.
Then run the free command and find that the used is now 66mb,free for 182mb,buffers 0mb,cached 11MB. So effectively released buffer and cache.
The usage of/proc/sys/vm/drop_caches is described below
/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 which 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 (8).
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.