How to clean this? - Memory used as disk cache by Linux

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
kpp550
Level 1
Level 1
Posts: 41
Joined: Tue Apr 14, 2020 4:16 am

How to clean this? - Memory used as disk cache by Linux

Post by kpp550 »

Okay so i was using Kdenlive andd after that suddenly this appeared.

"Cache" under memory (i have highlighted in the screenshot, i am providing below)
Attachments
Screenshot from 2020-10-09 00-39-34.png
Last edited by karlchen on Mon Nov 23, 2020 1:53 pm, edited 1 time in total.
Reason: Title. suffixed "Memory used as disk cache by Linux", which makes the question complete and understandable
User avatar
Blackwolf_Ozz
Level 1
Level 1
Posts: 3
Joined: Mon Aug 17, 2020 12:13 am
Location: Melbourne Australia

Re: How to clean this?

Post by Blackwolf_Ozz »

The Linux kernel provides an interface to drop the cache let’s try out these commands and see the impact on the free setting.

Code: Select all

# echo 1 > /proc/sys/vm/drop_caches
# free -m
Linux Mint & Kodachi 2.0
User avatar
antikythera
Level 9
Level 9
Posts: 2671
Joined: Thu Jul 02, 2020 12:52 pm

Re: How to clean this?

Post by antikythera »

Cached files in RAM are kept until another program needs the RAM. It's default linux kernel memory management behaviour. Take a look at www.linuxatemyram.com
Don't take life so seriously, nobody gets out alive anyway!
AMSTRAD CPC6128 - 128KB RAM, 3" Hitachi Floppy Diskette Drive, External Sony Cassette Recorder, Locomotive BASIC 1.1, CTM-644 Monitor
User avatar
CtrlAltDel
Level 5
Level 5
Posts: 859
Joined: Sun Jun 27, 2010 7:01 pm
Location: Birmingham, AL., USA

Re: How to clean this?

Post by CtrlAltDel »

antikythera wrote:
Thu Oct 08, 2020 5:00 pm
Cached files in RAM are kept until another program needs the RAM. It's default linux kernel memory management behaviour. Take a look at www.linuxatemyram.com
And even though it is normal and there is nothing wrong with that appearing, some users probably just aren't used to seeing memory cache listed in System Monitor. It's relatively new isn't it? System Monitor must have been modified in a recent update to allow that entry to appear.

I'm pretty sure it hasn't always been listed.
Image
Mint 20 Cinnamon / i7-4790 Processor
Nvidia GeForce GT 720 / 8 GB Memory
kpp550
Level 1
Level 1
Posts: 41
Joined: Tue Apr 14, 2020 4:16 am

why is there cache in my RAM? LM 20 Ulyana

Post by kpp550 »

why is suddenly there's cache tab under my ram usage?
i have a feeling that the ram usage + cache ~ 7.5 gn which leave only 500 mb ram.
(why do i think that? since my system is lagging/freezing the more those numbers go up)
Attachments
see in the red square.
see in the red square.
Last edited by karlchen on Sun Nov 22, 2020 8:10 pm, edited 1 time in total.
Reason: New thread Nov. about old topic "Linux cache memory" merged into existing thread from October 2020
User avatar
karlchen
Level 21
Level 21
Posts: 13525
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: why is there cache in my RAM? LM 20 Ulyana

Post by karlchen »

Hello, kpp550.

It has always been like this, only gnome-system-monitor before Mint 20 (Ubuntu 20.04) has not bothered to display so:
It is part of the way how Linux manages the system memory:
Memory which has not been assigned to applications may be used as disk cache.
In case applications request more memory, Linux will reduce disk cache in order to fullfil those requests.

Best regards,
Karl
Image
Linux Mint 19.3 64-bit Cinnamon, Total Commander 9.51 64-bit
Haß gleicht einer Krankheit, dem Miserere, wo man vorne herausgibt, was eigentlich hinten wegsollte. (Goethe)
User avatar
antikythera
Level 9
Level 9
Posts: 2671
Joined: Thu Jul 02, 2020 12:52 pm

Re: why is there cache in my RAM? LM 20 Ulyana

Post by antikythera »

take a look at www.linuxatemyram.com which explains exactly what is going on here.
Don't take life so seriously, nobody gets out alive anyway!
AMSTRAD CPC6128 - 128KB RAM, 3" Hitachi Floppy Diskette Drive, External Sony Cassette Recorder, Locomotive BASIC 1.1, CTM-644 Monitor
User avatar
CtrlAltDel
Level 5
Level 5
Posts: 859
Joined: Sun Jun 27, 2010 7:01 pm
Location: Birmingham, AL., USA

Re: why is there cache in my RAM? LM 20 Ulyana

Post by CtrlAltDel »

kpp550 wrote:
Tue Nov 17, 2020 1:53 pm
why is suddenly there's cache tab under my ram usage?
i have a feeling that the ram usage + cache ~ 7.5 gn which leave only 500 mb ram.
(why do i think that? since my system is lagging/freezing the more those numbers go up)
You aren't the only poster to have this same question, Kpp, including me. In this:

viewtopic.php?f=90&t=332316&p=1900253&h ... r#p1900253

thread, you'll see it also being discussed. Karlchen gives a great answer though in that it's always been like that but just recently has it been graphically displayed so that everyone could easily see it.

If your system is lagging, and or freezing, as those numbers climb, it has nothing to do with the cache entry being displayed in System Monitor, but something to do with your memory being consumed. That is a whole other topic and likely you would need to provide more information on your system setup perhaps in another thread with another, more descriptive, title.
Last edited by CtrlAltDel on Tue Nov 17, 2020 5:55 pm, edited 1 time in total.
Image
Mint 20 Cinnamon / i7-4790 Processor
Nvidia GeForce GT 720 / 8 GB Memory
hayden
Level 2
Level 2
Posts: 78
Joined: Thu Apr 07, 2011 7:59 am
Location: Texas, USA

Re: why is there cache in my RAM? LM 20 Ulyana

Post by hayden »

I had a question about how memory worked freenas (freebsd) when i thought mem was full and my coworker sent me this link.

https://www.linuxatemyram.com/
kpp550
Level 1
Level 1
Posts: 41
Joined: Tue Apr 14, 2020 4:16 am

Re: How to clean this?

Post by kpp550 »

Blackwolf_Ozz wrote:
Thu Oct 08, 2020 3:57 pm
The Linux kernel provides an interface to drop the cache let’s try out these commands and see the impact on the free setting.

Code: Select all

# echo 1 > /proc/sys/vm/drop_caches
# free -m
okay, okay i see. but here's the thing so u r telling all those lags and freezing until this point were caused by this?
how can limit this thing?
or even disable it?

bcuz that thing literally compleyelu uses my ram i got 7.7 and it easily goes to 5.9 gib and ram usage 2.0 ram usage. this is been getting on my nerves.
tell me how one can put a limit to it.

Code: Select all

 echo 1 | sudo tee /proc/sys/vm/drop_caches 
i guess u meant this code.
User avatar
antikythera
Level 9
Level 9
Posts: 2671
Joined: Thu Jul 02, 2020 12:52 pm

Re: How to clean this?

Post by antikythera »

Check what extensions are enabled in firefox. Disable them one at a time and see if the runaway ram consumption disappears.
Don't take life so seriously, nobody gets out alive anyway!
AMSTRAD CPC6128 - 128KB RAM, 3" Hitachi Floppy Diskette Drive, External Sony Cassette Recorder, Locomotive BASIC 1.1, CTM-644 Monitor
User avatar
karlchen
Level 21
Level 21
Posts: 13525
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: How to clean this?

Post by karlchen »

Hm.
This thread started in October 2020
kpp550 wrote:
Thu Oct 08, 2020 3:19 pm
Okay so i was using Kdenlive andd after that suddenly this appeared.
"Cache" under memory (i have highlighted in the screenshot, i am providing below)
looks precisely like that thread started in November 2020:
why is there cache in my RAM? LM 20 Ulyana
kpp550 wrote:
Tue Nov 17, 2020 1:53 pm
why is suddenly there's cache tab under my ram usage?
Merging the 2 threads: done
Image
Linux Mint 19.3 64-bit Cinnamon, Total Commander 9.51 64-bit
Haß gleicht einer Krankheit, dem Miserere, wo man vorne herausgibt, was eigentlich hinten wegsollte. (Goethe)
kpp550
Level 1
Level 1
Posts: 41
Joined: Tue Apr 14, 2020 4:16 am

Re: How to clean this?

Post by kpp550 »

karlchen wrote:
Sun Nov 22, 2020 8:05 pm
Hm.
This thread started in October 2020
kpp550 wrote:
Thu Oct 08, 2020 3:19 pm
Okay so i was using Kdenlive andd after that suddenly this appeared.
"Cache" under memory (i have highlighted in the screenshot, i am providing below)
looks precisely like that thread started in November 2020:
why is there cache in my RAM? LM 20 Ulyana
kpp550 wrote:
Tue Nov 17, 2020 1:53 pm
why is suddenly there's cache tab under my ram usage?
Merging the 2 threads: done

thanks for doing that!
i had forgotten bcuz of covid here.
Anyway how one can put a limit on ram caching?
User avatar
antikythera
Level 9
Level 9
Posts: 2671
Joined: Thu Jul 02, 2020 12:52 pm

Re: How to clean this?

Post by antikythera »

Set a higher vfs_cache_pressure value in /etc/sysctl.conf which you'll need to edit with sudo rights. Save and then restart to observe if the changes are desirable or not. Most people with SSD drives and a decent amount of RAM normally halve the value which increases the amount of data cached rather than reducing it.

However you'll need to experiment to find the sweet spot and the default is 100. The entry format for that is below:

Code: Select all

vm.vfs_cache_pressure=100
Don't take life so seriously, nobody gets out alive anyway!
AMSTRAD CPC6128 - 128KB RAM, 3" Hitachi Floppy Diskette Drive, External Sony Cassette Recorder, Locomotive BASIC 1.1, CTM-644 Monitor
Post Reply

Return to “Newbie Questions”