1

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
user12145
  • 1,075
  • 6
  • 26
  • 47

3 Answers3

6

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.

Aron Rotteveel
  • 8,239
  • 17
  • 51
  • 64
2

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

Pablo Martinez
  • 2,326
  • 16
  • 13
0

The cache is for speed up the disk I/O operations.

As Linus Torvalds once said, "free memory is bad memory". Linux kernel uses unused (by system/applications) memory for cache, should a program require more memory, the system gets it from cache.

lrosa
  • 1,657
  • 14
  • 15