this post was submitted on 26 Nov 2024
423 points (100.0% liked)

196

667 readers
102 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] MystikIncarnate@lemmy.ca 11 points 1 week ago (3 children)

I work in tech, and I don't understand people's obsession with having all their RAM free at all times.

If you don't use it, why do you have it?

Windows (not the best OS, but the one I know the most about), will lie to you about how much memory you have that's free. It puts data in RAM as cache. In the event you need that data, it's already loaded in RAM. Usually this is stuff like DLLs and executables for programs.

There's a difference between "free" memory, and "available" memory.

In addition, RAM is always going down in price, so 32G today costs what 16G did, some number of years ago. The same can be said for 16G vs 8G, etc. Though, the comparison becomes less relevant as you get into much smaller and older memory types, since the cost per dimm will only ever go so low.

Buy the memory, use as much of it as you can, as often as you can. Go wild with it. Enjoy.

[–] Draconic_NEO@lemmy.dbzer0.com 12 points 1 week ago

There’s a difference between “free” memory, and “available” memory.

I agree with this, and I'm sure most people complaining about Firefox or Chrome's abhorrent memory usage would too. The problem with most browsers is that they eat up the available memory and often do not give it back. So you end up with situations where you're running low on available RAM even though you have 32GB installed.

Buy the memory, use as much of it as you can, as often as you can. Go wild with it. Enjoy.

Sure, if you release it when not using it, otherwise unlimited RAM privilege revoked. Memory leaks suck and when they chew up all your RAM and they continue to happen, offending apps should either be no longer used, or limited to their minimum necessary RAM requirements to limit the damage they'll do.

Hence why I capped Firefox at 8GB, anything more would be wasted when it inevitably leaks.

Desktop file to limit Firefox to 8GB of RAM

[Desktop Entry]
Version=1.0
Name=Firefox RAM limit 8GB
GenericName=Firefox Ram limit 8GB
Comment=Limit RAM for Firefox to 8GB;
Exec=systemd-run --user --scope -p MemoryLimit=8G firefox
Icon=firefox
Type=Application
Terminal=false
Categories=Utility;Development;
StartupWMClass=Firefox

[–] Johanno@feddit.org 9 points 1 week ago (1 children)

Use all the RAM you want, but if another program needs it give it back ffs!

[–] Draconic_NEO@lemmy.dbzer0.com 3 points 1 week ago

Browsers have a really hard time with the last part. Hence why I recommended limiting it to something more manageable, that way it doesn't chew up everything available.

[–] cypherpunks@lemmy.ml 5 points 1 week ago* (last edited 1 week ago)

I work in tech, and I don’t understand people’s obsession with having all their RAM free at all times.

If you don’t use it, why do you have it?

Windows (not the best OS, but the one I know the most about), will lie to you about how much memory you have that’s free. It puts data in RAM as cache. In the event you need that data, it’s already loaded in RAM. Usually this is stuff like DLLs and executables for programs.

There’s a difference between “free” memory, and “available” memory.

Linux and macOS do the same, although I wouldn't call it lying per se :)

There is certainly a lack of understanding of the difference between free and available RAM. TLDR: yes, free RAM is indeed wasted RAM.

If you actually have a lot of free RAM, it's probably because you either booted or freed a lot of RAM very recently. After using your computer for a while, most of your available RAM should not be free but rather being used for page cache and other caches.

After a program has just read and/or written more data from disk than will fit in available RAM, the kernel's page cache (which is typically the bulk of that not-free-but-available memory) should be mostly populated by the most recent of those operations. This means that if that program (or any other program) reads those files again, before they are evicted from cache by other things, they will not need to wait for the disk and will get them back much faster.

However, managing all of this is the kernel's job, and the not-free-but-available RAM being used for page cache is not (in any OS, as far as I know, though I mostly know Linux) attributed to the program(s) responsible for putting things there.

So, when people are complaining about an application using 40% of their RAM it is not necessarily due to them misunderstanding free-vs-available RAM. The used number for an application does not include the portion of the system's not-free-but-available RAM which the application is also responsible for occupying.

(If you want to know which programs and/or which files are responsible for occupying your page cache... on Linux at least, it is not really possible without instrumenting your kernel. The kernel is just tracking blocks. There several tools which will let you see which blocks of a given file are cached, but there isn't a reverse mapping from blocks to files.)