cancel
Showing results for 
Search instead for 
Did you mean: 

Cache Memory

 
Raju_S
Frequent Advisor

Cache Memory

Hi All,

Want to know how to clear the RAM Cache memory in Linux.

Thanks & Regards
6 REPLIES
Steven E. Protter
Exalted Contributor

Re: Cache Memory

Shalom,

reboot.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Wouter Jagers
Honored Contributor

Re: Cache Memory

Hi,

Next to rebooting your machine, I don't think there's a way ;-)

The OS releases cache memory when more memory is needed by your processes, though, so there should be no need to worry.

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
Tobu
Occasional Advisor

Re: Cache Memory

Would like to know why you want to clear cache ? Are you getting any cache error messages ? Does your system support hotswapable memory ?

Ivan Ferreira
Honored Contributor

Re: Cache Memory

Extrange question. You don't need to clear the cache/buffer as the OS handles this for you when memory is needed for applications.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Mike Stroyan
Honored Contributor

Re: Cache Memory

You probably don't really want to do that. But here is a script that will tend to clear out page cache. It fills the cache with the contents of a sparse file which is then removed.

#!/bin/sh
# Empty the file system cache.
# Use reading a sparse file to fill the cache with pages from the file.
# Then remove the file to release the pages from cache.

MemTotal=$(awk '/MemTotal/{print $2}' /proc/meminfo)
dd if=/dev/zero of=/tmp/sparsefile bs=1K count=1 seek=$MemTotal
dd if=/tmp/sparsefile of=/dev/null bs=1M
rm /tmp/sparsefile
Raju_S
Frequent Advisor

Re: Cache Memory

Hi All,

Thanks for your response.

Regards