Why do browsers sometimes drain a lot of RAM until rebooted?

480 views

Why do browsers sometimes drain a lot of RAM until rebooted?

In: 5662

18 Answers

Anonymous 0 Comments

Some browsers treat each tab as a separate process. Each as it’s own program so to speak. So each gets its own little slice of RAM and it adds up. And sometimes the browser doesn’t give the RAM back even after closing some tabs. Rebooting clears out the memory.

Anonymous 0 Comments

If something drains a lot of ram until rebooted it’s usually a memory leak. It could also be that a tab activates once you open it. So maybe you have 100 tabs open and over the course of time, more tabs get opened and more memory is used.

If the browser itself has an actual memory leak I think switching browsers might be a good idea. I dont think i have noticed my browsers memory leaking but i could also not have noticed it so not 100% sure on how often this happens.

Anonymous 0 Comments

Almost all browsers have a feature where they optimise the user experience by in efficient use if ram. Download as much of everything and keep it ready for the user so they don’t have to wait. Sometimes they aren’t always sure what to not keep and it stacks up. With them releasing memory if other program wants it can lead to useless things it thinks are useful hanging around.

But here is a thing that modern programmers do: if you got resources free that you can use: why not use them? This means they don’t need optimise their code to be efficient, which is difficult and pointless when you have lots if resources to use. Just download all the libraries! You got 32 gigs of ram to waste, no one cares if 2gigs of it are libraries that are used for one single function that us equivalent of few lines if code! You got deadlines to meet!

Anonymous 0 Comments

Imagine two office workers. They both need multiple.documents at the same time to work. One of them is organised and only keeps the files it needs on the desk putting others neatly in the cabinet. Another one simply takes whatever they need and keep piling documents throughout the day.

When you reboot it’s like the end of day forces all office workers to put all the documents away. This way, even the sloppy worker starts clean every day.

The sloppy worker causes something called a memory leak, and why exactly it happens to browsers more commonly is more technical. Probably on of the reasons is because we tend to use them throughout the day more often then other programs. Another factor is that browsers don’t close in the proper sense, instead keeping themselves semi-active in order to give the impression they work faster.

Anonymous 0 Comments

A computer has a limited amount of memory. When a program wants to use something, it asks to borrow it. This is called memory allocation. Some programs are really good at returning something as soon as they are done with it.

The others fall into two categories.

One is programs that borrow memory but then forget they did. They don’t return it. This is called a memory leak.

The other hoards memory because it isn’t well written it it needs lots to do what it’s trying to do. This is called a bloated pile of crap.

In all cases, when a program closes, it lets go of all the memory it borrowed and it gets reclaimed.

Anonymous 0 Comments

People in this thread keep mentioning memory leaks. This explanation is wrong.

Browsers try to keep a copy of things you might need prepared in advance. Often if a browser feels snappy, it’s because rather than waiting for the thing you asked for to be downloaded of the internet, they kept a copy from the last time you asked for it. In fact, for extra snappyness, they keep it in RAM.

Browsers like chrome assume that they are the main thing you do on your computer, and will shamelessly take up more and more memory on the off-chance that you ask for something they are keeping. It gives them that quick snappy feel, but also makes them memory intensive.

Anonymous 0 Comments

[removed]

Anonymous 0 Comments

For whoever needs to hear this: RAM usage that seems high does not always mean a “memory leak”, it is often intentional. If no other processes are claiming the memory the active process might claim it. It will let go as soon as another process needs it.

Anonymous 0 Comments

[removed]

Anonymous 0 Comments

This is a bit too complicated for ELI5, so I’ll have to gloss over a lot of details.

There are multiple layers of memory management, at least two. There’s the virtual memory system that manages the entire computer and a heap allocator that manages each process.

The reason why you need this division is that creating a memory object needs to be *really* fast. Switching CPU protection modes is too slow; you should make memory-management decisions within each application without calling the operating system.

Long-lived applications hold on to some of their free memory so that they don’t need to immediately turn around and ask for it back. **This means a system monitor cannot show you that free memory.** The OS doesn’t know about it!

The system-level layer doesn’t ask for memory back. **It takes what it needs,** if and when it needs it. It measures how long it has been since memory was accessed, identifies “cold” pages that probably won’t be accessed again, backs them up to swap if needed, and unmaps those pages without the application even knowing.

The result of this multilayer model is that if you have only one long-running application that can find uses for memory, that application *should* end up filling your physical memory. On a scale of 1 to fine this is usually fine. **You can’t judge the memory usage of a browser unless you have something else competing for memory.** That’s when you can meaningfully look at statistics like refaults and pressure stall.

If there’s actually too much memory in use, performance falls apart as the system spends more and more time juggling data and less executing instructions. The solution then is to crash tasks – and without that threat, applications probably shouldn’t proactively return free memory to the OS.

[Firefox has the ability to detect when the system is in trouble and will back off](https://hacks.mozilla.org/2021/10/tab-unloading-in-firefox-93/). Android tells apps to design a response for “free memory or crash” threats. Server Linux can use Facebook’s new-ish oomd – if a server starts to swap heavily then it should log for statistical analysis, crash, and fix itself.