Confine memory usage by modifying kMaxRenderersByRamTier[], possible?

73 views
Skip to first unread message

Jeff Fang

unread,
Nov 26, 2010, 2:51:33 AM11/26/10
to Chromium-dev
Hi all,

I'm working on porting Chromium to a memory limited device and would
like to confine the memory usage in Chromium itself.

I read the comment of kMaxRenderersByRamTier[] as follows:
// Defines the maximum number of renderer processes according to the
// amount of installed memory as reported by the OS. The table
// values are calculated by assuming that you want the renderers to
// use half of the installed ram and assuming that each tab uses
// ~40MB, however the curve is not linear but piecewise linear with
// interleaved slopes of 3 and 2.
So my idea is to cut all the values in kMaxRenderersByRamTier by half
and Chromium will use only a quarter of the memory.
As I am new here, could anyone please tell me I am right or wrong?

Thanks

Regards,
Jeff

PhistucK

unread,
Nov 26, 2010, 3:59:13 AM11/26/10
to jeff...@acer.com.tw, Chromium-dev
I think it only controls the maximum number of renderer processes, not the memory they use. The processes themselves will try to increase their memory usage (if needed), as much as they can and when there is an out of memory exception (or anything else that provides Chrome with this information), it will probably crash (I guess it will try to garbage collect first).

PhistucK




--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
   http://groups.google.com/a/chromium.org/group/chromium-dev

Anton Muhin

unread,
Nov 26, 2010, 12:54:08 PM11/26/10
to jeff...@acer.com.tw, Chromium-dev
Jeff,

I don't think it'll work. For example, v8 (JS engine behind Chromium)
has a separate memory management (in most of the cases not even
calling into malloc and stuff and using underlying OS page management
API.)

So the number in the comment (40M) is a rough estimation, not a hard limit.

Making Chromium run in a limited amount of memory might be quite
challenging, even for modern desktop there are various scenarios which
lead to high memory consumption (for example, some extensions inject
huge objects into various frames, etc.). One way to achieve that wold
be to put strong limits on some memory usage (for example, v8 allows
that). But if your device is really limited and notable amount of
pages would die with OOM, you might need to add a lot of stuff which
would allow to survive when memory usage gets high---the endeavor the
complexity of which should not be underestimated.

yours,
anton.

Carlos Pizano

unread,
Nov 29, 2010, 1:45:18 PM11/29/10
to Chromium-dev, Anton Muhin, jeff...@acer.com.tw
Reducing the number of renderers will indeed reduce the memory usage
but not by half. Memory usage is proportional to how many sites you
have open and how much memory they use.

So how much you can save by tweaking this number? well, you are going
to have to experiment:

1) Set the max to say 3, rebuild
2) Load 20 sites that have a stable (predictable) usage of resources.
3) Using about:memory compare the memory usage of your build and a
regular chrome with same sites loaded.
4) Report back to us.

Jeff Fang

unread,
Nov 30, 2010, 12:52:00 AM11/30/10
to Chromium-dev
Hi Carlos,

Actually, I did some experiment by removing 1G RAM of my laptop (2G to
1G). I put the result on the google docs, hope you can see it.
https://docs.google.com/leaf?id=0B4FkycsLm9nONDU1NTA3NjktNjQ3NS00ZjUzLTljN2MtYWEzZjBmMjEyZjAz&sort=name&layout=list&num=50

The slope gets gentle when 11st site opened. It's reasonable as the
kMaxRenderersByRamTier is 14 for 1G RAM, no more new process are
created.
Interesting part is, when more than 22 tabs are opened, the memory
usage seems to be limited to 380MB. I am trying to figure out why
there's a such limit. Is it because the swap or Chromium is doing
something behind. If anyone has any idea, please let me know.

regards,
Jeff
> > On Fri, Nov 26, 2010 at 10:51 AM, Jeff Fang <jeff_f...@acer.com.tw> wrote:
> > > Hi all,
>
> > > I'm working on porting Chromium to a memory limited device and would
> > > like to confine the memory usage in Chromium itself.
>
> > > I read the comment of kMaxRenderersByRamTier[] as follows:
> > >  // Defines the maximum number of renderer processes according to the
> > >  // amount of installed memory as reported by the OS. The table
> > >  // values are calculated by assuming that you want the renderers to
> > >  // use half of the installed ram and assuming that each tab uses
> > >  // ~40MB, however the curve is not linear but piecewise linear with
> > >  // interleaved slopes of 3 and 2.
> > > So my idea is to cut all the values in kMaxRenderersByRamTier by half
> > > and Chromium will use only a quarter of the memory.
> > > As I am new here, could anyone please tell me I am right or wrong?
>
> > > Thanks
>
> > > Regards,
> > > Jeff
>
> > > --
> > > Chromium Developers mailing list: chromium-...@chromium.org
> > > View archives, change email options, or unsubscribe:
> > >    http://groups.google.com/a/chromium.org/group/chromium-dev- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages