
Firefox fixes save gigabytes of memory on image-heavy pages - AndrewDucker
https://blog.mozilla.org/nnethercote/2013/10/01/memshrink-progress-week-117-120/
======
spyder
I just compared it with Chrome using the example page mentioned in article:

In Firefox Nightly at the initial page load it uses around 250 MB memory and
with scrolling it stays around that.

In Chrome (in Canary too) initial it uses around 300 MB but scrolling keeps
filling the memory indefinitely (I stopped scrolling above 1.2GB)

~~~
aktau
Yea, I also noticed that, save for the pages with tons of images, firefox has
actually been better than chrome in that respect for the last few releases.
Now with this fix, I'm seriously thinking of jumping back. Then I'll finally
have my sweet DownThemAll again. Many kudos to the firefox devs, performance
and memory-usage is very important, and it seems they realized that before it
was too late. Even with my 16GB I'd really like to run an extra VM for
development as opposed to letting my browser gobble it all up.

~~~
Peaker
Last I tried Firefox, pretty recently, it still needed to address some serious
issues, when compared to Chrome:

* Unresponsiveness due to one tab thrashing

* Bad use of screen-space (bookmarks always visible, cannot disappear titlebar like in Chrome [there's only a Windows extension for that], menu-bar takes up another bar of space by default)

* Launching firefox has stop-the-world behavior to check/update extensions -- interrupting your flow when you need your browser most

* Some extensions still require restarts

These are the ones I remember off the top of my mind, I'm sure there were
more...

I really tried going back to Firefox, but the cumulative pain of all of these
made me go back to Chrome.

~~~
jimmaswell
Firefox's UI is the most customizable of any browser that I know of. You can
really make it into almost anything you want. My example:
[http://i.imgur.com/aMgQBgW.png](http://i.imgur.com/aMgQBgW.png) very clean
and functional.

~~~
Peaker
I couldn't find any customization that removed window decorations in Linux. I
found ones for Windows only.

Also, I got the (subjective) feeling that Firefox was becoming sluggish as I
had 6-7 addons. I might be wrong, but that would mean Firefox is sluggish in
general.

~~~
sergiosgc
If you can't do it through extensions, you may be able to remove window
decorations using the window manager. The configuration is dependent on the
specific window manager that you are using, but it should be possible.

~~~
Peaker
In Chrome it Just Works...

Firefox has had years to catch up to Chrome with these issues, why haven't
they?

------
icebraining
Great news! Many thanks to Timothy Nikkel and all the other Mozilla devs. It's
particularly great on Fennec, where the memory constraint is noticeable.

For people - like me - who didn't know what B2G was, it's Boot2Gecko, the OS
project: [https://wiki.mozilla.org/B2G/FAQ](https://wiki.mozilla.org/B2G/FAQ)

~~~
soapdog
Check out [http://firefox.com/os](http://firefox.com/os) for a user view of
Firefox OS and [https://developer.mozilla.org/en-
US/docs/Mozilla/Firefox_OS](https://developer.mozilla.org/en-
US/docs/Mozilla/Firefox_OS) for a Developer view.

------
mnarayan01
Like many of the other Firefox memory changes, this one leaves me feeling a
little ambiguous. On the one hand, obviously keeping memory usage down is
good. On the other hand, waiting to decompress/decode images until they are
visible to the user means that there are obviously going to be performance
trade-offs (and also, obviously, design/engineering trade-offs).

Speaking just from my personal usage: I don't think there has ever been a time
where delaying the image decompression on a page would ever have had any
utility for me (at least from a memory standpoint). On the other hand, there
have been plenty of times when eagerly performing image decompression would
make my browsing a bit smoother.

All in all, it seems (from a not-particularly-in-touch outsider perspective)
as if Mozilla went from being totally dismissive of memory complaints to being
hyper-responsive to memory complaints with no (publicly stated) rationale
behind the change. It would be interesting to see the reasoning behind this
(if only from an intellectual standpoint), particularly given that in many
cases I tend to feel that it would have been better to simply be a bit more
diplomatic when rejecting memory-based bug reports.

~~~
AshleysBrain
If image decoding is asynchronous (don't know - guessing it is already?) and
you decode them when they get near to the viewport and not just when they
become visible, then it should always be decoded by the time you scroll to it
and yet never jank the page. Scrolling a long way really fast probably means
there's a small delay while it decodes images, but surely that's worth it to
save gigabytes of memory?

~~~
mnarayan01
> but surely that's worth it to save gigabytes of memory

I'm not sure _save_ is the right word here...using available memory has no
particular cost to me over not using it. Of course, the _available_ modifier
is relevant, so I take your point.

~~~
scholia
It's a huge advance for those of us who usually have 50-60 tabs open for weeks
at a time, where hitting a really heavy image page would tip Firefox over the
top and crash it.

I switched from Chrome to Firefox a couple of months ago for its ability to
handle more tabs without slowing/crashing, and for its better performance with
image-heavy pages. So, for me, it's not just "who cares?" it's a killer
feature.

~~~
Touche
Tabs are not bookmarks. Use bookmarks.

~~~
dbaupp
Why should one use bookmarks rather than many tabs? I have many concurrent
projects going, and things I refer to regularly, so I just leave them grouped
in my tree of tabs on the sidebar. Much more efficient than digging through
nested bookmark menus, or trying to make sure the bookmarks are properly
classified.

Basically, my tabs are bookmarks, except tabs are integrated into the web-
browser better.

~~~
dragonwriter
So, the problem is that the bookmark UI design is broken.

~~~
dbaupp
My bookmark UI isn't broken: putting tree-style tabs in a sidebar is perfect.

~~~
jlgreco
If they would make the tree-style tabs very aggressively swap to disk, or even
discard state entirely and seamlessly become a bookmark that would reload when
clicked _(perhaps this behavior could work only for white-listed domains, like
wikipedia.org)_ , that would be perfect.

The main usability problem with bookmarks over tabs AFAIC is that the bookmark
UI does not encourage pruning bookmarks, so most become stale over time.

Another idea I've been kicking around for a while is "tab decay". Have tabs
start to decay and close themselves after not being viewed for a configurable
amount of time. 1 month would probably do it for me, it would save me a lot of
cleanup time.

------
adamtulinius
I wish people would use regular 2d plots for 2d data.

Other than that, great news!

~~~
eterm
Technically it's 3D data, with the three axes being {Time, Memory Usage,
Version}.

But I agree there may be a better way of visualising this data.

~~~
mattlutze
Technically it's three trials of 2D data, with the axes being Time and Memory
Usage. The width of the lines given by the version axis is for visibility, not
to encode data.

A 2D line graph with 3 colors for the different versions would be an
appropriate visualization. This one suffers spatial distortion and is only
useful in confirming that yes, they use less memory in step 2 now.

~~~
mistercow
>The width of the lines given by the version axis is for visibility, not to
encode data.

Bar graphs do exactly the same thing in a 2D graph. Would you suggest that all
bar graphs be replaced by a one pixel wide stacked bar graph?

Of course not, because even though the samples in a bar graph are discrete,
they convey order. It's the same here. The width of the lines is only for
visibility, but the Z position of the lines conveys version order. A 2D line
graph would only convey that by labels. And if labels were as useful as visual
position, we could just replace all graphs with lists of numbers.

I personally found this graph trivial to read and comprehend. The spacial
distortion is canceled out by the fact that the differences we're looking at
are very large, and the steps axis is spaced out sufficiently to line up the
points visually.

My only complaint is that it shouldn't be a line graph, as the steps are not
continuous.

~~~
mattlutze
I do agree that a style with discrete steps would also be appropriate.

To the other points, no, not all bar graphs do the same thing. Bar graph bars
are often the width they are due to data binning, where the width has
significance.

The graph _was_ trivial, but made less clear by the 3D isometric projection.
the spatial distortion is reduced but not canceled out by the space.

3D pie charts share the same failure. Yes, as long as the tilt is slight, they
are still mostly readable. But it will make "closer" wedges appear larger and
"farther" wedges appear smaller. It's visual dishonesty and unnecessary.

Just because one can finagle understanding out of a visualization does not
make it a good visualization.

------
reidmain
Is it time to switch back to Firefox from Chrome? I remember when I originally
switched around Firefox 3.5.x Chrome was much leaner and faster. Has the
pendulum finally swung back the other way?

~~~
shmerl
I never saw a reason to switch to Chrome to begin with. Performance was
acceptable for me, while other benefits always made Firefox more useful
(privacy with encrypted Sync, better add-ons and etc.). And some time ago,
Firefox clearly became a leader in performance as well.

All this "jumping to Chrome" was simply a hype thing IMHO, and I generally
don't care about hype.

~~~
syncerr
From a developer standpoint, the dev tools in Chrome far exceed those in
Firefox. The nightly releases are just starting to compare.

~~~
shmerl
I rarely use those. And there is also Firebug.

------
nikbackm
Good to see continuing improvements in the browser of the free and open net.

------
rplnt
Tried the page with Opera (12.xx) and it peaked at around +850MB and within
seconds backed down to the initial value (+0MB). No change during scrolling.
How is that possible? Does the browser hold bigger pool and just got rid of
other stuff?

------
chestnut-tree
Completely unscientific test: if I load the following website in Firefox 24
(on Windows 8), the page scrolls very sluggishly (as it did in previous
Firefox versions). The same page scrolls fine in Chrome. I don't know what is
causing the difference. Is it the images? Or something else? For info, Firefox
is my main web browser and I have never switched to Chrome (nor do I intend
to).

Warning - the website is ridiculously image heavy (it's a gallery of Android
app screenshots)

[http://androidniceties.tumblr.com/](http://androidniceties.tumblr.com/)

------
Sarkie
Chrome is starting to be a nightmare to use, might have to go back to Firefox.

I can't get meaningful help if it freezes or doesn't load and it can't deal
with 50% of the router pages, IE only :(

------
sfjailbird
Sounds great - does anyone know how this compares to Chrome (both in terms of
approach and results)?

~~~
bru
As spyder says in another thread of this post, on the given page
([http://congressoamericano.blogspot.fr/p/fotos-do-
congresso-a...](http://congressoamericano.blogspot.fr/p/fotos-do-congresso-
americano-iii.html)) Chrome decodes and decodes... the memory usage goes up
and up. I was using 1.5GO of memory before closing it (and still far from
having loaded everything).

~~~
kamjam
Do you know if the tabs run in separate processes yet (like Chrome) or will a
crash/memory leak/long running script cause the whole browser session to
close?

~~~
kevingadd
They don't in Desktop firefox, they do in Android firefox

------
ksec
For those Complaining about Firefox Responsiveness. There are e10s Reboot (
Process Per Component or tab ) that they are working on. Generational GC, New
Graphics Backend etc.

------
warcode
I returned to Firefox (Aurora) a couple of months ago, but i am currently
starting to inch towards chrome again.

While reduced memory usage is good, it doesn't help when has major problems
handling multiple open tabs with flash player, has problems with javascript-
heavy pages, and the firefox profiles STILL degrade in performance over time.

I really don't want to remake my FF profiles every 2 weeks just to avoid
performance issues.

~~~
cpeterso
What Firefox add-ons are you using? You shouldn't need to rebuild your profile
every two weeks. How much does rebuilding your profile improve performance?

------
neurostimulant
> When loading the page, physical memory consumption would still jump to
> almost 3 GB, because the images are still decoded. But it would soon drop
> down to a few hundred MB, as the decoded data for non-visible images was
> discarded, and stay there (with some minor variations) while scrolling
> around the page.

This is a great news. The application that uses the most memory on my machine
is the web browser.

I wonder if this fix would make scrolling the page less smooth.

~~~
nnethercote
> I wonder if this fix would make scrolling the page less smooth.

It shouldn't. But why don't you try it?

------
acdha
Interestingly, this optimization is already unnecessary if you are using the
common technique of setting the CSS background-image on an element rather than
using IMG src - on Chrome, Firefox and even Internet Explorer memory usage
will be stable on a grid of images that way and, as a bonus, you trivially get
cross-browser scaling and centering for vertically scaling thumbnails to be
the same size.

------
PedroBatista
Excellent news! This problem was so bad that after only a couple pages of porn
gifs on Tumblr i had to open Chrome to keep the smut going.

------
mark-r
I switched to Chrome recently because Firefox was growing overnight to the
point where it started thrashing and becoming unusable. I just checked and it
says I already have the latest version. This recent change must not be the
whole story.

~~~
what_ever
The latest changes done as part of this are only present on Aurora (Firefox
alpha) and the feature is turned off by default.

Also, I have my Firefox (Aurora again) running for over a week now on my dev
machine with > 50 tabs open an I have had no issues with memory. I suppose
there is some problem with one of your add-ons. Try creating a clean profile
and see if it's any different.

------
trustfundbaby
If Firefox would find a way to let Chrome extensions work in Firefox, that
would definitely make it a little easier to switch back and forth, definitely
going to try this out though.

------
Avitas
Nice. This means that SeaMonkey will be getting these updates a day or two
after FF.

------
anentropic
Or alternatively... Firefox fail was previously wasting gigabytes of memory on
image-heavy pages

~~~
01Michael10
Gee, the trolls are up early today...

~~~
morkbot
On one hand true, on the other - it isn't that those fixes are some magic,
extra smart hackery (at least on the idea level, dunno about the
implementation). Don't load an image that user don't see, remove an image that
user saw but don't see anymore - those seem as rather obvious solutions.

~~~
kamjam
The great thing about Firefox is that if something is so obvious, you could
also contribute to the development effort...

~~~
billiam
right on. Please spend as much time reading the bug referenced above as you
have this thread, and think about the obvious problems/hard solutions
proposed, then make a better one! Just keeping a few million WinXP machines
from a recycling barge in Bangladesh for another year would be worth the
trouble. and hopefully smarter image handling by everybody's
browser/phone/whatever will be a long term result.

