Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Chrome is designed to be memory hungry. It doesn't NEED the memory, but if it's there it sure as hell will use it to try and speed up your internet experience.

What's the point of having a tonne of ram only to let it sit idle?

I "only" have 4 gb of ram and chrome is taking up 1.2 gb of that, even though i have 12 windows open with ~5 tabs in each.



"Idle" memory is used by the operating system as cache. On my computer, 800 MiB of my RAM is in use by programs, but 1.7 GiB of my 2 GiB RAM is used in total, by programs, buffers and cache.

The problem is that an extension like "1-Up for Google+" doesn't need 20 MiB of RAM just to play a sound and display a green mushroom, for a total of about 150 KiB of assets and maybe a few KiB of code.


I've never used "1-Up for Google+" but are you sure it's really only 150KiB worth of assets, if you are measuring file sizes you are looking at compressed data which is useless to your computer.

You'd be surprised how big uncompressed data can get, compare a .BMP with a .PNG of the same image for example.


I had uncompressed data in mind, but it was only a rough guess. I'll do a more in depth calculation.

2 seconds of uncompressed sound, at 44.1 kHz, in stereo and 8 bits per sample is 170 KiB. 17 images of on average 24 by 24 pixels at 32 bits per pixel is 68 KiB. Three other, bigger images give another 40 KiB of uncompressed data. A total ~280 KiB. There's a few KiB of HTML but I don't know whether and how I should count that. Even if we take into account headers, padding, objects and higher quality data (e.g. 16 bits per sample), I assume all assets will still account for less than half a megabyte.

Now that I look at the code, I see it's including a bundled version of jQuery. I don't know how big the representation of Javascript code is in memory, but 29 MiB seems a bit much (correction, while I was typing this, it went to 31 MiB).

It might seems disingenuous to single out this extensions, but truth to be told all my extensions need a similar, way too high amount of private memory.


Most likely it's the javascript etc, it may also be holding syntax trees etc in memory too?

If it causes the load of another library which nothing else was using that could count especially if it's a different version of jquery etc.

If 2 processes are both using the same library and it is linked to their addresses spaces, who's memory usage does it count against?


Neither, as I am only looking at private memory, which is by definition not shared. Interestingly, most of my extensions have 0K shared memory, which implies they're all keeping their own version of JavaScript libraries in their own memory space. That might explain most of the problem. It doesn't seem easy to solve a problem like this, without reinventing the shared library and the accompanying "DLL hell".


And in fact the memory isolation between javascript execution contexts is one of Chrome's most touted security features.


Why is the default to let any app take as much as it can? Or, perhaps more to the point, why can we not force apps to live within X megs of RAM, regardless of what we have available (for whatever reason we choose)? If it's a possibility to do that, it's pretty nigh hidden to everyone.


You have to give an app whatever memory it asks for, or it will crash. If it doesn't use that memory, the OS will swap it to disk.

Apps don't generally change their behavior based on the size of physical RAM, but maybe Chrome does this as a very advanced optimization.


We should be able to tell the OS - "don't give app X more than 300meg" and let the OS handle swapping directly, regardless of what the actual RAM is.


How would you know how much RAM is going to be needed by a process?

Let's say you load up you video editing program, maybe it only needs 512MB of memory to fit the whole program into memory, now what happens when you load in LOTR directors cut?

Especially if you aren't running any other large programs, would it still make sense to restrict it to 300MB (or 1GB , or 2GB etc)?

I think it's safer to assume that OS developers know what they are doing and can be trusted to handle memory contention issues better than most of us can.

As an aside some programs (like redis , memcached etc) do allow you to restrict the amount of RAM which they use but this is because they are explicitly greedy with memory and are probably used by people with enough skills to measure actual usage and tune accordingly.


"How would you know how much RAM is going to be needed by a process?"

I don't necessarily. I just know how much RAM I want to be able to give it.

I'd love to be able to test apps in lower-RAM scenarios. Just because I've got 8g or 16g doesn't mean everyone does, but I have no way to test what that experience will be like.

Additionally, I may have two processes that are both rather RAM hungry that I need to run. Give me the option of constraining one of them so that I can give RAM priority to one or the other rather than "oh, well the OS people are smarter than me, so I guess I have to trust that app 1 will get RAM priority over app 2, or they'll just both have to be equal".


If you want to artificially constrain memory in order to test performance in low memory systems then this is a different use case entirely and I'd be surprised if there is not software available to do this for you.

Although you should bear in mind that computers with less memory probably have less everything else (including slower memory busses) so your best bet is to actually find a slower computer and test with that.

Most OSes will let you prioritize other processes over others (e.g Linux has "nice"), whether this is just for CPU preemption priority or whether it does other resources as well I'm not sure.

However I think most swapping systems will try and keep the most frequently used pages in RAM , so if one process has preemption priority over another this problem would solve itself as it's memory area would just get accessed more often.

Again this is kind of finger in the air stuff so anyone more familiar with OS design should feel free to correct me.


The operating system can use this to cache files, which greatly improves read and write performance.


Exactly, free memory is wasted memory.


for the open source chromium, there's a command line option to set how quickly it should release memory to the OS:

https://wiki.archlinux.org/index.php/Chromium_Tips_and_Tweak...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: