Thursday, October 10, 2013

How to Decrease Memory Cache in Linux Permanently (free -m)

www.unixbabuforum.inWe see more memory is showing in "cache" when we look for "free -m" output. We would want to decrease/limit the cache. Could you let me know if there are any permanent ways to do that. 

Ex: (free -m) 
total used free shared buffers cached 
Mem: 3825 3687 137 0 344 1837 

Here cache is 1837, i want to reduce it permanently. Sometimes times, if the RAM size is big, it even takes more cache. Just looking for a permanent solution to free up cache. 

www.unixbabuforum.inIf you could force cache to be lower, then you just have a bunch of memory doing absolutely nothing. It will not be used more effectively by processes. At least if it is cache, it might save some I/O if data is re-accessed. 

Don't worry about it being unavailable for new processes, etc. It will have been committed to disk if it changed, and it can be made available as free store just by changing a couple of flags in the kernel. Cache memory is just as available as free memory when it is needed.

www.unixbabuforum.inYou don't need to decrease cache memory size. Memory management of Linux is very intelligent

www.unixbabuforum.inIt is better to leave things as they are unless you are using a Database 
and know very well what you are doing, most OS's keep recent filesystem 
data in cache to reduce the number of I/O operations needed to disk, such 
as file and directories attributes, and data recently written do a file, 
etc..., in very few cases, such as databases kept in filesystems, this 
caching mechanism is counter productive as double caching takes place, the 
Database and OS keep in cache recent data, for these few cases you can 
enable "direct I/O" on the filesystem which would get rid of the double 
caching issue, but if you are using regular files, whether they are binary 
or not, direct I/O would only cause an I/O bottleneck. 

Another characteristic of filesystem cache is that it uses whatever the 
Application is not using, or at least has lower priority, the OS will swap 
filesystem cache out before application memory segments. 

If your server is not paging, it has enough RAM, if it is paging, removing 
the filesystem cache will only make things worse. 


Post a Comment

Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM