Linux memory cached release

Source: Internet
Author: User

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)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.