deleting linux cached ram [duplicate]

Solution 1:

Clearing caches will hinder performance, not help. If the RAM was needed for something else it would be used by something else so all you are doing is reducing the cache hit/miss ratio for a while after you've performed the clear.

If the data in cache is very out of date (i.e. it is stuff cached during an unusual operation) it will be replaced with "newer" data as needed without you artificially clearing it.

The only reason for running sync; echo 3 > /proc/sys/vm/drop_caches normally is if you are going to try do some I/O performance tests and want a known state to start from (running the cache drop between runs to reduce differences in the results due to the cache being primed differently on each run).

The kernel will sometimes swap a few pages even though there is plenty of RAM it could claim back from cache/buffers, and tweaking the swappiness setting can stop that if you find it to be an issue for your server. You might see a small benefit from this, but are likely to see a temporary performance drop by clearing cache+buffer artificially.