What Can I Do If the Buffer and Cache Occupy Too Much Memory of a Linux ECS?
Symptom
When querying the system memory usage using free after the Linux ECS runs for a long period, you have found that most of the memory is used by buffers and cache.
Possible Cause
In Linux memory management, buffer refers to the buffer cache, and cache refers to the page cache.
- Buffer cache, which caches data that is read from and written to disk blocks
For example, if the system writes a file, respective page cache pages will be modified, and buffer cache buffers will be marked as dirty. When writing dirty data back to the disk, the kernel only writes back the changes, rather than the entire page, to the disk.
- Page cache, which caches file data that is read from and written to files in file systems By default, Linux caches the read file data in the memory to facilitate quick data access.
Normally, Linux automatically releases buffers and cache if the system requires more memory, and a high cache memory usage does not affect the system performance.
Solution
Buffers and cache are necessary for the smooth running of systems and devices in Linux. If the cache is forcibly cleared, disk data needs to be read from the disk, which decreases the system performance.
To clear the buffers and cache, run the following command:
echo 3 > /proc/sys/vm/drop_caches
The command execution may take several seconds, depending on the memory size. After the command is executed, the occupied memory will be released.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot