Linux cache

Hi,

We are working on OEL5.7 (Oracle Linux) OS. We have a server with 64GB RAM. When we issue free -m command which shows the used, available and cached space. Most of the space is shown in cached section, where as we are not really doing much activity on the server.

It's like cached is somewhere around 23GB, how can we see what is in it which is cached and how do we clear it?

Thanks and Regards!

You are having the standard Linux Newbie Memory Freakout. Cache memory counts as free memory.

Linux uses every spare bit of memory to cache all disk accesses, because memory which sits around doing nothing is useless. But cache will be recycled for other uses as needed. It's only sitting around as cache right now because it's not needed. Large amounts of cache are to be expected on an unloaded and idle system.

You want to have at least some cache, anyway. If you use so much memory that there's nothing left for cache, this is a problem -- disk access will become slow. The more cache you have, the more efficient disk access can become.

Do not, repeat, do not reboot your system, plug weird values into /proc/ to "flush the cache", and so forth. Everything is fine.

1 Like

Why would you want to clear it? The cache is available as free memory if an application requires it. This is a better use of memory in case you need to recall the contents of a file that has been read.

1 Like

Thanks alot Corona688 and mark54g for the detailed information..

Yes, the only time you really want to drop caches (all right, the one time I can think of right now) is if you are testing disk read performance for comparison. Then you do want to drop caches so as to make the tests equal.

Always Pointed..
Your free RAM = free + catched + Buffer (as your catched will going to be utilized when out of sapce )

 
# free -m
                 total   used       free  shared buffers cached
Mem:              374     108        265    0      9       55
-/+ buffers/cache:        43         330 
Swap:             580      0         580

So here actual free RAM = 265 + 55 + 10 = 330

Yes.. '-/+ buffers/cache: ' is nothing but this value .. but on older version Linux this line is absent so calculate by above formuli ...

To Flush Out Catch and buffer memory ( Do it on your own risk if important application is running on your server live dev)

 
## Find where is file "drop_caches" in your kernel proc 
 
# find /proc -name drop_caches
/proc/sys/vm/drop_caches 
 
#  sh -c sync; echo 3 > /proc/sys/vm/drop_caches
 
Now see the difference 
 
# free -m
              total       used       free     shared    buffers     cached
Mem:           374         50        323          0          0          9
-/+ buffers/cache:         41        332
Swap:          580         0         580

--Shirish Shukla