Sunday, August 5, 2012

How to free cache/buffer memory in linux


If you have 4GB of memory on you linux machine you will notice that there is around 1 GB (depends on many factors) of memory not used by applications but are consumed from memory


This section of memory is used by the kernel as cache and buffers to speed up linux applications


You can check how much memory is used in cache by running this command


free -m

--------------------------------------------------------------------------------------
> free -m
                     total       used       free     shared    buffers     cached
Mem:          3865       2955        910          0         35       1235
-/+ buffers/cache:   1684       2181
Swap:         4199        524       3675

--------------------------------------------------------------------------------------
 
As you can see there is 1.2 GB of memory used by cache, and also the output shows that if the cache is cleared i will have  2.1 GB of free memory instead of 910 MB


How to clear Cache ?
Run the following command:

sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"














No comments:

Post a Comment