this post was submitted on 26 Nov 2024
454 points (97.7% liked)
196
16588 readers
1929 users here now
Be sure to follow the rule before you head out.
Rule: You must post before you leave.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
What is the acceptable amount of ram a browser should be using? Is there a way of knowing how much is “wasted”? Is it even possible to waste ram, like what is wasted, time? Electricity?
If an app allocates it and ever uses it and refuses to give it up unless killed that can be considered wasted. It's called a memory leak and they can be really bad, especially when they consume a lot of memory, as that memory might as well be empty but is being held hostage by other apps.
If they released RAM then whatever amount they were using wouldn't be wasted and if more is needed they'd simply release it to free up resources. That hasn't been happening though, and most modern Browsers are notorious for consuming massive quantities without releasing it back to the pool.
In that case with the presence of Memory leaks being considered, and the fact that they continue to not be fixed, the acceptable amount of RAM a browser should be using (should even have access to) is the minimum necessary to run smoothly. From my testing with Firefox that seems to be 8GB. 4GB caused many websites to struggle. Such an arrangement ensures that even if a Browser begins eating RAM it won't eat up all the RAM and cause issues, worst that'll happen is that it itself will crash from eating all the 8GB it was allowed to access.
Its being wasted if a memory leak causes it to use all 32 gigs of ram and crash
Even if it doesn't eat that much if it latches on to a portion of Memory and won't give it up unless killed that's still bad, and would be considered wasted as nothing else can use it for anything.
It's only a problem if it doesn't give it up when other apps need it and there's not enough. Browsers just cache a bunch of shit in memory for speed and convenience, but they should unallocate it back to the pool if something else calls for it. The internet complaining about this for years and years are mostly doing so from a place of ignorance.
The issue is that browsers don't release much memory back to the system when it's needed. I wish they'd work more like the Linux kernel's VFS caching later, but they don't (and might not be able to. For example, I do don't think the Linux kernel has good APIs for such a use case).
You can write limits to and then poll files in
/proc/pressure/
to be notified of resource pressure. Systemd will also set an environment variable for similar files for your cgroup.The issue is that browsers don't release much memory back to the system when it's needed. I wish they'd work more like the Linux kernel's VFS caching later, but they don't (and might not be able to. For example, I do don't think the Linux kernel has good APIs for such a use case).
It does release it back to the system. It only doesn't if you actively have a ton of windows/tabs open, in my experience. Even then, it'll cache stuff to disk after awhile. Like on my phone, I've easily had over 20 tabs open in Firefox (Android) and it doesn't suck up all of my phone's ram (which only has 12GB). If your system is running less than 16GB, then that's another matter and you really should add more, as 16GB is pretty much the baseline on computers these days.
Mine is 32GB and Firefox as consistently and repeatedly refused to release the excess RAM back into the pool. So it doesn't work out as well in practice as it does on paper. I would agree that 16GB is the bare minimum though and if you have less you absolutely should get more if you can. Firefox needs at least 8GB to run smoothly, but a system that only has that amount or less will be bogged down by Firefox alone.
Empty ram is wasted ram. In theory the system should use whatever is available to cache and streamline.
Somehow I don't really agree with that theory when Firefox was chomping down on 31.5GB of RAM and causing other things to crash or slow down (crashed Gnome shell a few times which was fun), as well as crashing often itself. When I limited the RAM to 8GB using the method outlined in my other comments all the mentioned issues went away. It would run smoothly, and old tabs would just unload, something which didn't happen before. And most of all, everything else ran smoothly without issues or hiccups.
Moral of the story, when apps leak RAM, limit their RAM. RAM held by apps and not being released is just as wasted as if it wasn't used at all, because chances are it isn't being used at all, and isn't able to be used.