1

After reading this link: How do you empty the buffers and cache on a Linux system?, I know that there are some commands that can help us to empty the buffers and cache of the OS.

But I'm not sure if it is safe. For example, if I execute those commands to empty the buffers and cache on my linux server, in which some web services have been deployed. Will this have some probability to cause some issues or some errors about the web services?

Yves
  • 3,291
  • 1
    Flushing the cache is probably not what you want to do. It's not that it's unsafe, but it provides you no benefit unless you have an extremely specific reason to do so (e.g. you're debugging a possible problem with the pagecache). – forest Sep 08 '22 at 02:38
  • 1
    @forest it's very useful for performing benchmarks. – Artem S. Tashkinov Sep 08 '22 at 12:34

1 Answers1

3

Yes, it is safe.

At most, it will slow down disk reads a little until the cache is filled again....because the first read (after clearing the cache) of any cacheable data from the disk will have to come from the disk rather than the cache.

Linux routinely discards data from cache when it needs the memory used by cache for something more important (like running programs). It is meant to dynamically fill up and clear according to demand.

cas
  • 78,579