Linux memory cached release
When we use the free command to view the system memory usage, we will find that:
# Free-m
1. total = used + free
2. cached is relatively large, and I have even met a situation where the memory is only 7 MB left. In this case, cached is very large and almost equal to total, at this time, when files are opened or files are transmitted, the available memory is very small, and the program may use swap partition swap, so it will find that the machine speed is slow.
How can we solve this problem that causes machine slowdown?
The culprit is that the memory has been cached, and the free is basically gone.
So we should think about how to release the cached memory.
Restarting the machine will certainly solve the problem, but we certainly cannot use this method.
There are three release methods (the default value is 0, and you can change it back to 0 after release ):
To free pagecache: echo 1>/proc/sys/vm/drop_caches
To free dentries and inodes: echo 2>/proc/sys/vm/drop_caches
To free pagecache, dentries and inodes: echo 3>/proc/sys/vm/drop_caches
Indeed, this immediately solved the memory problem.
Root @ localhost ~] # Free-m
Total used free shared buffers cached
Mem: 15940 7187 8753 0 326 4824
-/+ Buffers/cache: 2035 13905
Swap: 18127 0 18127
[Root @ localhost ~] # Echo "1">/proc/sys/vm/drop_caches
^ [[A ^ [A [root @ localhfree-m
Total used free shared buffers cached
Mem: 15940 1903 14037 0 0 29
-/+ Buffers/cache: 1874 14066
Swap: 18127 0 18127
Related reading:
Linux high-end memory ing (I)
Linux high-end memory ing (medium)
Linux high-end memory ing (medium)