Thursday, May 9, 2024
71
rated 0 times [  71] [ 0]  / answers: 1 / hits: 178283  / 1 Year ago, fri, december 9, 2022, 10:56:24

After the system starts, in a few minutes my memory cache fills up and it starts using the swap. Here's a screenshot of /proc/meminfo.



memory



However, if I can disable this process / clean the cache once after that, I think my system will speed up to some extent. Correct me if I am wrong here.



I have also tried Bleachbit memory cleaning, but it doesn't seem to clean the memory cache properly. Also, the feature is still in an experimental stage.



bleachbit memory



There was already a similar question posted here: How can I disable the prefetch cache?, but it was regarding Ubuntu Server, and also the answers involved manual settings etc.



So, I want to know if there's some software for disabling/enabling Memory Cache for Ubuntu 12.04.


More From » software-recommendation

 Answers
1

Note: Linux is NOT "eating" your RAM! Please take a look at Geirha's excellent answer below to understand why...



After the above note, if you still feel "cleaning" the cache could help, you can certainly try: it's a one-liner from the terminal:


sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

There's no easy way to disable the cache, but you can achieve the same effect by cleaning it as often as every minute, if you want to:



  • Make it a cron-job



  • Press Alt-F2, type gksudo gedit /etc/crontab, and add this line near the bottom:


    */15 * * * * root sync && echo 3 > /proc/sys/vm/drop_caches



  • This cleans every 15 minutes. You can set to 1 or 5 minutes if you really want to by changing the first parameter to * or */5 instead of */15




One liner to know REAL free RAM, excepting cache


Geirha's answer explains the details, but in short, you get the number of free megabytes with:


free -m | sed -n -e '3p' | grep -Po "d+$"

which on my 2GB command-line server returns an extremely health 1835.


[#37300] Sunday, December 11, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rcraftemur

Total Points: 118
Total Questions: 119
Total Answers: 144

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
rcraftemur questions
;