0

I try to clear the cache and buffer. Because they grow very much and starting use some swap. Will it affect the system? The system running in production. Or is there any other solution?

    Memory
                  total      used       free     shared    buffers     cached
    Mem:           31G        31G       207M       1.6M       331M        22G
    -/+ buffers/cache:       7.9G        23G
    Swap:          15G       281M        15G
1

2 Answers 2

1

You have only 281MB in your swap, while your total memory usage is 31 gigabytes. That is 1% of your total memory.

Most likely the data in your swap is so rarely used that it is better to be left over there, and use the resulting free memory for buffers / caches, which actually speed up system operation.

Unless you have strong evidence that the system slows down due to swapping and large buffers / caches, you should not drop buffers / caches.

1
  • 1
    I would strengthen that statement: do not drop caches. They already are low priority, and the cost of warming them up again is so high, that it will not be worthwhile. Maybe set vm.swappiness=1 if you want to avoid paging out. Aug 29, 2017 at 13:28
1

I do second Tero Kikanen's answer. It looks very much like your system is doing exactly what it is supposed to do. It makes best possible use of your RAM (whatever RAM is not useful elsewhere gets used as cache, reducing disk access). Any data in RAM not used for a while gets swapped out, so you have more cache available, while some never-to-be-used-after-boot binary is sitting in your swap partition waiting to get swapped in later - which might happen only tomorrow or next week.

There are situations, though, where ths doesn't work quite well. For example a nearly idling machine transfers more data from one disk to another, than it has RAM available. Any binaries and their data not being used during that disk-to-disk transfer will get swapped out. Not a real problem, most of the time, but an inconvenience, when you return to your computer and want to continue browsing the web. Your browser might appear to hang for 10 or more seconds, and your productive but bored web server will take a few seconds until all it's binaries and data are back to RAM.

On a busy server, though, this doesn't happen, because before half of your cache is filled with data-being-copied, your binaries are used again, your cached data is used again, and your data-being-copied gets older than your actively used data. So the copies are dropped from cache, not your productively used data.

So don't empty your buffers and caches, you would slow down your machine.

TomTomTom

You must log in to answer this question.

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