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

3 Answers 3

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.

2

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

1
  • 1
    The appropriate command is slabtop, not slaptop :) Jan 14, 2010 at 11:10
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .