Clean up cached memory in Linux

When we use top or free -m -h command on terminal, we may have noticed the used memory.
When Linux first read or write data, it is stored on unused areas of memory to accelerate the data access for future use. It is called caching. If this data is read again later, it can be quickly read from this cache in memory. It greatly enhance system performance. When application needs more memory, a chunk of memory is cleared from cache and provided to the application.

“The Linux disk cache is very unobtrusive. It uses spare memory to greatly increase disk access speeds, and without taking any memory away from applications. A fully used store of ram on Linux is efficient hardware use, not a warning sign.”

We can check current memory status by using :

watch -n 1 free -m

This command will display memory status, updating every seconds.
Memory watch on linux

watch -n 1 cat /proc/meminfo

This command will provide detail memory status and usage.

Clearing cached memory :

sudo sysctl -w vm.drop_caches=3

This command will clear all cached memory space. And will not improve nor affect system performance.

Leave a comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.