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

25 views
0

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

In: 5662

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.

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.

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.

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!

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.