linux cache usage

My Centos box seems to be using lots of caching, most of the used memory is used for cache, how can I find out what the cache is for?

             total       used       free     shared    buffers     cached
Mem:      16439708   10469864    5969844          0     197936    9534176
-/+ buffers/cache:     737752   15701956
Swap:     16763816          0   16763816

Solution 1:

The cache memory in Linux-based machines is often used to cache disk blocks into memory to prevent writing to the harddisk and speed up I/O operations. Also, a lot of free memory is cached and released when it is actually required.

When interpreting the output of free, you should look at the second row for the actual memory usage.

The above numbers can be interpreted as:

  • 9534176 kilobytes cached memory
  • 737752 actually used memory
  • 15701956 actually free memory

For more information, take a look at http://www.faqs.org/docs/linux_admin/buffer-cache.html.

Solution 2:

You can look at /proc/slabinfo or use the command slaptop to have a top-like interface to the cache objects.