Memory leaks and web browsers

You can talk about almost anything that you want to on this board.

Moderator: Moderators

User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Memory leaks and web browsers

Post by Bregalad »

I had some memory leaks problems with Opera, and after doing some researsh on the net, I figured that all the major browsers appear to leak memory as soon as a page is open.

Isn't it incredible how much memory it can take just to open a web page (usually 400 MB) and consideing that if you don't close your browser after an extended period of time it's going to eat >1GB of memory, just because the coders of those programs didn't know how to use malloc and free properly ?
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: Memory leaks and web browsers

Post by blargg »

User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Re: Memory leaks and web browsers

Post by Bregalad »

So basically you're saying I'm incompetent when it comes to using malloc and free ? Yes you are probably right, and I'd never get the competence of writing a web browser, so it's very easy for me to do blind criticism.

However, I still think it sucks that browsers tend to leak memory so much. But at least knowing the problem is good enough, I could explain a colleague why a PC he left on with both Firefox and Chrome running for a whole week ended up having some serious lagging problems at resume (with 100% of memory used and disc caching enabled etc etc...)
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: Memory leaks and web browsers

Post by blargg »

Is caching page assets a memory leak? Also, Reducing [Firefox] memory usage.

If blame is to be laid, I lay it squarely on website designers who bloat these things beyond recognition, slowing down multi-hundred-MHz smartphone web browsers. That is what requires such sophisticated web browsers that implementations are complex enough to leave unsolved memory leaks and need lots of caching and other memory-intensive approaches to running at an acceptable speed.
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Re: Memory leaks and web browsers

Post by Bregalad »

Is caching page assets a memory leak?
No.
But then the cache shouldn't take 1GB or RAM either I think. This means more than 1 CD-ROM of cached data ? Makes few sense to me.

And I agree that bloated websites are quite annoying, even though I never access internet from a phone.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Memory leaks and web browsers

Post by tepples »

It's not necessarily entirely the fault of the browser implementation. JavaScript running on an interval can periodically add things to an array, add listeners to a DOM element, etc. Should a browser just force-close a page whose script uses too much memory?
User avatar
TmEE
Posts: 789
Joined: Wed Feb 13, 2008 9:10 am
Location: Estonia, Rapla city (50 and 60Hz compatible :P)
Contact:

Re: Memory leaks and web browsers

Post by TmEE »

Opera does not seem go beyond the limit if you set one. I keep a 400MByte memory cache and I don't see memory use grow beyond that even after days of use. Firefox eats up all the memory I have pretty quick...
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Memory leaks and web browsers

Post by koitsu »

Does Opera have something equivalent to about:memory like in Firefox? If you use FF, close all instances (i.e. exit the browser entirely), launch it, and go to about:cache and about:memory (and click Measure) sometime. Prepare to be incredibly pissed off.

This is just how a lot of software is today -- "our" days of KISS and minimal resource usage are pretty much over; we're a dying breed of peoples. The "web" today often consists of so much unnecessary bullshit.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Memory leaks and web browsers

Post by tepples »

That's why I have tried my best to design web applications with as little unnecessary BS as possible. How would you rate the bloat level in, say, Phil's Hobby Shop?
User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 521
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Re: Memory leaks and web browsers

Post by Jarhmander »

tepples wrote:That's why I have tried my best to design web applications with as little unnecessary BS as possible. How would you rate the bloat level in, say, Phil's Hobby Shop?
IT'S OVER NINE THOUSAND
((λ (x) (x x)) (λ (x) (x x)))
3gengames
Formerly 65024U
Posts: 2281
Joined: Sat Mar 27, 2010 12:57 pm

Re: Memory leaks and web browsers

Post by 3gengames »

How do you not understand, if RAM is open, the web browser will compile javascript (well, chome will) an show it all to RAM to gain speed? I know this has come up.

And Chrome doesn't leak much memory to me. Firefox will destroy any computer left open for 2-3 days though. Opera, never used long enough to see how it's backsides were made. And IE probably doesn't leak much I'd bet, you have to be fixing something when you don't care about standards. :)If your
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Memory leaks and web browsers

Post by rainwarrior »

3gengames wrote:Firefox will destroy any computer left open for 2-3 days though.
? I regularly have Firefox open continuously for days. I'm not sure why you think this. At various times, various builds of each of the major browsers have had serious flaws, often manifesting for only a small subset of users, perhaps you had a bad experience with Firefox at some point, but it will hardly "destroy any computer". I've had builds of Chrome, Firefox, and Opera that failed to run well for me at the time, but in general I think all three of them are kept in good working order most of the time (not sure about Opera these days, haven't used it regularly in the last few years).
koitsu wrote:This is just how a lot of software is today -- "our" days of KISS and minimal resource usage are pretty much over; we're a dying breed of peoples. The "web" today often consists of so much unnecessary bullshit.
There was never a day of minimal resource usage. Webpages are generally designed without concern for the efficiency of resources- there are always examples that are as bloated as they can be for the contemporary available resources. Same with all computer programs. Designing and implementing these things for efficiency has never been the majority goal there.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Memory leaks and web browsers

Post by tepples »

rainwarrior wrote:Webpages are generally designed without concern for the efficiency of resources- there are always examples that are as bloated as they can be for the contemporary available resources.
For one thing, "contemporary available resources" can range down to an Atom netbook or an ARM tablet or smartphone. See discussion about frustration with garbage collection overhead in web browsers on slow, RAM-starved mobile devices.
Same with all computer programs. Designing and implementing these things for efficiency has never been the majority goal there.
The server side of a popular web application may need to serve several customers per second on each server behind the load balancer. Or a game for a late-generation console or handheld game system may try to raise scene complexity compared to competitors' games.
Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

Re: Memory leaks and web browsers

Post by Grapeshot »

I had an issue with Chrome a year ago where certain tabs would leak 400k or so of memory per second while they were in the background. This included very simple web pages from the 90s and would go to the point where one page was using over a gigabyte. I think part of the problem had to do with trying to cache every single decoded frame of an animation as it was running, even when it was offscreen.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Memory leaks and web browsers

Post by rainwarrior »

tepples wrote:For one thing, "contemporary available resources" can range down to an Atom netbook or an ARM tablet or smartphone. See discussion about frustration with garbage collection overhead in web browsers on slow, RAM-starved mobile devices.

The server side of a popular web application may need to serve several customers per second on each server behind the load balancer. Or a game for a late-generation console or handheld game system may try to raise scene complexity compared to competitors' games.
Yes, as always there are applications which require lighter / optimized implementations. Doing this is a specialized skill, and it's not needed for most cases. The majority of people take the naive path, and either don't have a problem at all because their task is incomplex, or don't notice the poor performance of their stuff because it's not really an issue to them, and/or they don't care about how it runs on more limited platforms that they don't use themselves.

For example, the recently released Hate Plus visual novel game has horrendous performance, and it uses all available CPU on its thread at all times even though it is largely just static screens of text. It causes a mild annoyance for people playing it (lag between input and feedback, jerky transitions, etc.), and I suppose causes a waste of electricity, heats up my laptop and gets that fan going annoyingly loud, etc. but it doesn't make the game non-functional at all. All these things annoy me, and the issue is probably really easy to fix for a programmer who is specialized in optimization, but it's not enough of a problem that its author is going to solve it. I'm not trying to single out Hate Plus, it's just an example-- a great deal of indie games have very poor performance for what they do.

There have always been programs and games and websites that run slowly and use way too much memory. Yes, resources were a bit tighter in the past, but the result was just that people managed to accomplish less complicated things before they hit their performance barrier. There was never a good old days when people cared more about performance, that's always been specialized.
Post Reply