/Proc is a virtual file system. we can use its read/write operations as a means to communicate with the kernel object. in other words, you can modify the file in/proc to adjust the current kernel behavior. then we can adjust/proc/sys/vm/drop_cach...
/Proc is a virtual file system. we can use its read/write operations as a means to communicate with the kernel object. in other words, you can modify the file in/proc to adjust the current kernel behavior. then we can release the memory by adjusting/proc/sys/vm/drop_caches. the procedure is as follows:
[Root @ server test] # cat/proc/sys/vm/drop_caches
0
First, the value of/proc/sys/vm/drop_caches. the default value is 0.
[Root @ server test] # sync
Run the sync command manually (description: the sync command runs the sync subroutine. If you must stop the system, run the sync command to ensure the integrity of the file system. The sync command writes all unwritten system buffers to the disk, including modified I-nodes, delayed block I/O, and read/write ing files)
[Root @ server test] # echo 3>/proc/sys/vm/drop_caches
[Root @ server test] # cat/proc/sys/vm/drop_caches
3
Set/proc/sys/vm/drop_caches to 3
[Root @ server test] # free-m
Total used free shared buffers cached
Mem: 249 66 182 0 0 11
-/+ Buffers/cache: 55 194
Swap: 511 0 511
Run the free command and find that the current used is 66 MB, free is 182 MB, buffers is 0 MB, and cached is 11 MB. this effectively releases the 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 that memory to become
Free.
To free pagecache, use echo 1>/proc/sys/vm/drop_caches;
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 shoshould run sync (8) first.