T
T
tehnazavr2019-05-15 03:09:43
linux
tehnazavr, 2019-05-15 03:09:43

How to reduce disk cache on linux?

Hello. I have 16gb of ram installed in my linux laptop. When I run several programs, a code editor, 40 tabs in chrome, everything starts to slow down and new programs simply cannot open, and about 150 - 200 mb are written freely in the memory usage information. At the same time, the disk cache never occupies less than 60% of the total amount, it always only takes more (I see it in the same place).
From what I've found, the disk cache should allocate some memory each time the programs run out of memory. But I repeat, it does not take less than 60%, i.e. As I understand it, he does not give anything. Who fumbles, tell me, did I understand this moment correctly?
I would like to reduce the amount of memory that the disk cache can occupy, but I can not find information on how to do this. An SSD disk is installed, of course not as fast as RAM, but in this situation it is better to let it read information from the disk than it takes up RAM.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xotkot, 2019-05-15
@xotkot

first, make sure that the problem is really in the disk cache (not swap), try resetting it when everything starts to slow down: running as superuser with the cache, you can immediately clean the inode and dentrie (this command includes the command above) p.s. if the problem really turns out to be in the disk cache, then you can configure the system so that it clears it more aggressively by setting the vfs_cache_pressure parameter to more than 100 (by default), for example: (will be valid until reboot) to fix this parameter in the system and after reboot, create, for example, file /etc/sysctl.d/60-sysctl.conf with the following content:
then reboot the system or just reload the configuration file itself:
To make sure the changes have taken effect, look at the output of the command:
sudo sysctl -a | grep vfs_cache_pressure

O
OnYourLips, 2019-05-15
@OnYourLips

and in the memory usage information it is written freely about 150 - 200 mb
Do you consider caches free or non-free memory?
And why if the previous option is "second", then you think that everything slows down due to lack of memory?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question