Hacker News new | ask | show | jobs
by keybuk 3023 days ago
(I have worked as an engineer on both Ubuntu and Chrome)

> One tab on chrome takes about 100MB memory, why?

It probably doesn't.

Much of that apparent memory usage is shared between all tabs, and the browser renderer process, etc. in the form of shared memory.

Quite a bit of it will be the executable code itself, which is "mapped" into memory, given an address, and allocated the full size but doesn't actually consume memory until it needs to be read from disk.

And a large part of that memory is going to be the giant white pixel buffer that you want it to draw into, which is typically mapped to a texture buffer in the GPU memory.

4 comments

If I Shift-Esc in Chrome with one tab open, it shows that this tab ("Add Comment") consumes 0 bytes of shared memory and 163 828 kB of private memory.

Current window size is 1280x800. Assuming the render buffer is ARGB32 and assuming one render buffer (which is probably an incorrect assumption) that should be ~40MB. The GPU memory is listed as a separate entry in that view, but I don't know if that is also included in the "private memory" listing.

Going turn off javascript and restart and see what it says then.

EDIT: 164 856 kB w/o JS. So no change (relatively).

Zero bytes of shared memory? So you have no other processes running which have libc loaded in?

    $ ldd chrome | wc -l
         124
Shift-Esc is Chrome's own task manager. I don't know how they count.
Additionally, the number you come up with (as "MiB of RAM used by an application") might also depend on the OS features the application uses and not directly be obvious by its functionality.

Example: I've been doing some experiments around DWM thumbnails in MS Windows. My program doesn't really do much and shouldn't use too much memory (and doesn't, at least initially). I create a thumbnail for each visible window on the screen (say 5 of them), and -ding-, my process uses >400 MiB.

But Windows itself does this when you hover over a taskbar entry, right? Explorer is never that heavy for me.

Or is the process totally different?

A compositor doesn't create a separate image for stuff like this. Every window is rendered into a texture and things like thumbnails are simply a small texture-mapped quad; it's done for each frame by the GPU.
Okay, may be OP's estimation of that being a per tab usage was not quite right, but why does ~30 tabs result in 3GB+ of usage?
May be happening for other people, but I've never had this happen. 60+ tabs and it never breaks 2GB.
My "private bytes" numbers very from 50 to 300MB per chrome process, so that's not counting shared memory or untouched memory.

An HD pixel buffer is only 6MB.

> An HD pixel buffer is only 6MB.

Don't forget that the browser splits out different layers and composites them together, so it'll be a little bigger than that.