

Chrome and Firefox 3.5 Memory Usage - RK
http://dotnetperls.com/chrome-memory

======
chops
_During the experiment, 384 memory checkpoints were taken, which amounts to
1152 seconds or 19.2 minutes._

My problem with Firefox has always been with having the browser open for a
long time (days) and running multiple tabs, including having an open Gmail
window constantly.

By that point, Firefox is always sluggish and painful. Closing the browser the
natural is a waste of time because it takes so long for the memory to free up,
and killing the process altogether is the only thing that does anything to buy
me some clock cycles.

I'd like to see the results of a long-term test of that nature.

~~~
ori_b
I agree. Closing firefox through file->quit takes at least 30 seconds for me,
during which I can hear the laptop's fan spinning up.

Usually I just kill -9 it because I don't have the patience to wait.

Firefox 3.0.11, on a dual-core low-voltage laptop with 1 gig of ram. It's fast
enough to run everything I care about but firefox.

~~~
JulianMorrison
C/C++ programs that manually memory free at exit are doing it wrong.

They ought to (1) write everything to disk they need to save (2) fsync (3)
send themselves a SIGKILL. The OS will tidy up the memory.

~~~
ori_b
SIGKILL? Uh, you know there is a little function called exit() that exits the
program.

Other than that, yes, I agree with you, but I suspect what's actually taking
all the time is paging back in the data that it wants to write to disk when it
syncs, and not necessarily freeing the memory.

~~~
JulianMorrison
SIGKILL because it gives finalizers and at-exit handlers no chance to run. The
building has been emptied: knock it down, don't waste time picking it apart
brick by brick.

I doubt that paging all the stuff it wants to write is the reason. If that
were the case, killing it during the grind would corrupt its save files, and
the time duration of the grind would be proportional to what needs saving
(just a few files of fairly constant size) versus proportional to how much
memory it's hogging.

I think it's paging all right - it's paging back in every fiddling little
object to call its finalizer.

~~~
ori_b
Ah, right. I wasn't thinking of C++ destructors, since I usually program in C
these days. In that case, you're probably right.

------
s3graham
Private bytes or address space? Shared readonly counted twice?

I happily suffer Chrome's stupid tab design and lack of Flash (on Ubuntu) for
much better end-to-end performance, whether it takes up more memory or not.

~~~
tdoggette
Why don't you like Chrome's tab design? I was a little off-put when I first
saw it, but it makes sense for tabs to live at the top edge of the screen from
a Fitt's Law perspective: when you move your mouse upwards to interact with
the browser, it's to deal with tabs (so they deserve the larger target). When
you want to hit the address bar, you hit ctrl+t to get a new tab in which it's
already selected.

~~~
s3graham
Tabs have always seemed like a horrible misfeature to me. The OS already
provides a taskbar, so now you've created N*M places to look. Not only that
but you can't see all the tabs at the same time once there's multiple windows,
so you have to pick a window, check all of its tabs, move to the next and
repeat. The "it's like MDI/documents/text editors" argument is bogus because
the window that contains gmail has nothing to do with the window that contains
HN, or reader.google, or whatever. It's like all the programs written in C++
get their own taskbar, separate from the ones written in VB, separate from the
ones written in JS. Except we only separate the JS ones for some reason.

For Chrome specifically:

1) it lacks the option "New pages should open in [X] a new window [ ] a new
tab" compared to Firefox, which makes tabs ignorable.

2) On Windows, I'd much rather they follow the OS conventions for MDI rather
than make up their own "cool"/"clever" one (see media/audio players, for some
random reason). All of a sudden, for example, you can't double-click in the
top left to close. Well, way to be clever, but that's crap.

~~~
snprbob86
The lack of top-left corner double-click drove me nuuuuts. Until I found out
that you could middle-click to close tabs.

------
lutorm
Is the huge memory use from Chrome just because it opens separate processes
for each tab? If so, can't some of that memory actually be shared by the OS
even though it shows up as duplicated (like what happens if you do vfork?)

~~~
dflock
Nope - the huge memory usage for Chrome is because this analysis is complete
rubbish - it's double counting all the shared memory for each process, as you
suggested.

~~~
barrkel
He is using Process.PrivateMemorySize64 in .NET. It doesn't double-count,
because it only counts non-shared pages.

Non-shared working set pages are probably the most relevant measure, as a
process-per-tab model will have lots of address space and may use memory
mapping extensively, and so have lots of non-shared pages, but not actually
touch many of those pages, and end up with a relatively small working set.
However, .NET's Process class doesn't have an equivalent property to Process
Explorer's "WS Private" column.

EDIT: Sure enough, a quick eyeball of some Chrome subprocesses using Process
Explorer gives me these results:

    
    
        Private        WS Private
           1416               460
          14916              7952
          12084              9780
          16780             13972
          16164             11336
          14812             12040
          10284              4444
          19140             15400
    

All numbers in KB. Non-shared working set impact on an unloaded machine,
probably the most important measure for Windows, is usually quite a bit less
than the private bytes.

------
Locke1689
Just to note - this is done on Vista, which means that the browser stats may
look very different on a different OS.

~~~
pyr3
I don't know if this is relevant or not, but Safari uses OSX's ported
libraries as DLLs. If the memory size of those DLLs is being used, it would
show up as less memory usage on an OSX machine due to those libraries being a
shared part of the main OS.

------
midnightmonster
Chromium dev list discusses these results:
[http://groups.google.com/group/chromium-
dev/browse_thread/th...](http://groups.google.com/group/chromium-
dev/browse_thread/thread/f97adb063b97a81)

TLDR: Vista's default memory readout is actually pretty good for simply adding
together like this and getting reasonable numbers WRT shared libs. Chrome
really does use tons more memory than FF 3.5 with simple pages in many tabs.
Chrome devs chose stability, security and foreground tab prioritization over
lower mem use on purpose. They don't think this test much reflects what people
actually do with their browsers.

------
notaddicted
4 GB of memory can be had for $50.

When I use a computer I usually use: browser + music, OR browser + emacs.

I want my browser to be fast and responsive, and the memory isn't being used
for anything else.

~~~
scscsc
I also want my browser to be fast and responsive, but the current trend goes
in the other direction. How on Earth can you occupy GBs of memory? How much
time does it even take to download a gigabyte of data?

~~~
phillmv
Of course, it's not the actual downloaded text that takes up all that memory.
It's not like programs take up gobs of memory because the programmers were
being lazy and disdainful.

No, it's the internal representation of the markup, and the program state of
all of the javascript programs a page might incorporate, that takes up a lot
of memory.

~~~
scscsc
That is obvious. What is less obvious is how much memory you can waste for the
internal representation. I would expect that the memory footprint of a well-
designed browser should be dominated roughly by the download size (w/out
taking into account the javascript code, which could keep a lot of state
around).

~~~
phillmv
> should be dominated roughly by the download size

Well, judging by the graphs in the linked article this is clearly something
that every browser vendor experiences. I imagine that the trade off in speedy
page rendering is having a lot of memory intensive data structures.

It's prolly more complicated than we give them credit for.

I've never liked the griping about memory use - if you're not swapping out to
disk then you're perfectly fine. I'm much more concerned with having firefox
occupying a whole core if I leave it unattended with too many js intensive
tabs open.

------
grandalf
what about firefox + firebug compared to chrome?

~~~
asyazwan
You mean compared to Chrome + Firebug Lite? <http://getfirebug.com/lite.html>

~~~
grandalf
oh cool hadn't heard of that !

------
greyman
Ok, but how to interpret the results? If the memory is not used, it is a
problem that Chrome takes up so much of it?

~~~
ori_b
The problem is that the memory is used by other programs when I want to start
them up.

Don't get me wrong, caches are great. However, it's one thing for the OS to
cache stuff, because it can easily drop caches when memory pressure rises.
Userspace software in current systems have no good way of knowing the memory
pressure, and no good way of responding to it by dropping caches to free up
memory. (yes, an API for "this memory is a droppable-at-any-time cache" would
be nice in OSes, but it doesn't exist at the moment, and getting one that's
easy to use would be hard).

More or less, that means that software that uses more memory in userspace
causes swapping and lame performance. And honestly, there is no good reason
for a browser to easily be the most resource intensive program on my system.
Even games tend to be far lighter than browsers.

~~~
dkarl
_an API for "this memory is a droppable-at-any-time cache" would be nice in
OSes, but it doesn't exist at the moment_

Naive question: would this be any better than letting applications provide
swapping hints to the OS? And is that any better than just letting the OS swap
based on usage?

~~~
ori_b
Yes, to a certain degree. The problem is that it would be cheaper to, say,
drop a decoded version of a JPEG and re-decode it, instead of having it get
swapped out. In fact, I suspect that for large images, it would be cheaper to
re-read the compressed jpeg and decompress it than to read back a larger
swapped out decompressed version, just because hitting the disk is slow, and
swap tends to get fragmented because it's usually written a few pages at a
time.

Swap hints probably aren't really worth the effort, although I haven't
benchmarked it.

The idea behind caches is to avoid doing expensive operations repeatedly, and
hitting swap is about as expensive as an operation can get.

------
sarvesh
You really can't compare a beta or Release Candidate with final versions of
other browsers that most definitely will put your numbers off.

~~~
scscsc
Do you have any strong data stating that the final release of some software is
in general more memory friendly as opposed to the beta version? I don't have
data for the counterpoint either, but I'm willing to bet the developers have
other priorities (i.e. bug fixes as opposed to optimization). Once you've
maldesigned your software w.r.t. performance, you can't do much except to wait
for hardware to catch up.

~~~
sarvesh
Beta versions of software include debug information. This is pretty much a
standard practice, even I do it. It helps me understand where things went
wrong and how it could be improved. When you do the final version you
generally get rid of the debug information which more often than not will
reduce memory consumption. This is different from optimization.

~~~
scscsc
I doubt the beta comes with debug information (not your beta, theirs). I don't
use Windows -- it should be easily checkable by someone who does.

