Hacker News new | past | comments | ask | show | jobs | submit login

(Disclaimer: V8 dev)

This post is unfortunately nonsense, because it's making a fundamental measurement error: not including renderer processes for Safari, and only measuring the browser process (which should be expected to be roughly O(1) memory in the number of tabs).

To the author's credit, they _are trying_ to include child processes - I'm not sure why, but `psrecord` seems to not (in local testing) include child processes for Safari even when the "--include-children" flag is passed. I guess it does for Chrome, for whatever reason.

I'm somewhat disappointed that the author, or half the comments on the post, didn't question these _wildly_ different results though...

OK, but the situation still looks shameful. What exactly prohibits a web site from consuming all my RAM? I have never once seen a browser make a misbehaving site wait (frozen with no CPU) for me to confirm that sucking up more RAM is acceptable to me.

What happens instead is that I hit a wall of slowness, forcing me to press the power button and lose all my other work. It's not very gradual, I think due to the nature of the problem, so the browser needs to avoid getting into the situation. It's like UI latency follows a hyperbolic curve, running right up to infinity all of a sudden as the RAM runs out.

What ever happened to computers being at least somewhat usable when all RAM is in use?

I seem to remember that being a pretty common condition back in the 90's. Things would get slow, sure, but not completely and utterly hosed.

When this happened to me recently (unattended Firefox process used up all RAM) the machine was simply never able to recover, even after killing the offending process (thereby making 30GB or so of RAM available) and waiting a half an hour.

For some reason, Linux is specially bad at working under load, both memory (too many applications & browser tabs open) and I/O (copying large files into USB drive).

Ohh this is absolutely infuriating for me (and for others as well [0], for quite a bit of time) on Linux desktop machine, when RAM is fully used OS just freezes and nothing besides reset with a button and potential loss of work can be done about that.


Is it because Linux is optimized more for server purposes rather than desktop ones (For example, when it comes to process scheduling)? I’m curious.

Not really seeing how being unable to recover without Alt-SysRq is any better on the server

It was nice when the OS was 64-bit and multi-threaded, but the browser was not. The browser couldn't grab more than 1 CPU and 4 GiB.

On modern macOS/Chrome it'll be impossible. But on other platforms you can still run 32bit chrome (other browsers)

Haha, yeah. I mean you can still use cgroups or something to accomplish this, right?

Back then, needing to smartly manage RAM (i.e. reserve space for what you REALLY needed; manage your own requests otherwise) was done.

Now, not so much. Dev machines rarely run out of RAM anyway.

> I have never once seen a browser make a misbehaving site wait

Isn't that what Firefox's "a tab may be slowing down your computer" (or equivalent) is doing? However it does not seem to trigger reliably. Good thing for me i disable JavaScript most times!

> I hit a wall of slowness, forcing me to press the power button and lose all my other work

So that's two parallel problems. First is browser is eating too much RAM. Second is OS starts writing to swap instead of triggering OOM killer, rendering the whole system unusable rather quickly. I personally systematically disable swap on laptops/desktops (but keep it on server).

Ideally, client-side scripting in the browser wouldn't be a thing at all (we'd have established, reproducible, secure software distribution mechanisms like guix's introduction channels). In a better world, a browser would for every page disable Javascript/WASM by default, but have a convenient menu (alla Noscript) to choose between different security/performance profiles: webapp for unlimited resources/permissions, simple for basic JS for minor interactions (like LibreJS does), etc..

In our world, the websites we consume decide what resources they're gonna eat, and how much network resources they're gonna load, leading to unexpected CPU/RAM/network usage (inducing €€€€ bills for cell phone data).

Chrome has a task manager that you can use to kill a stalled tab. The OS has a task manager that you can use to kill a stalled browser. You are never forced to use the power button and lose work.

That would be nice.

Reality: the task manager will not open because there is not enough RAM. Simply moving the mouse pointer can become impossible.

Attempting to close a window goes like this: estimate the mouse movement needed, carefully move the mouse, then come back in 15 minutes to see if the pointer has moved and if it is in the correct location. If it has moved but not as desired, make another attempt. If it hasn't moved, come back in an hour... then try several hours, or maybe the next day. If somehow the mouse is in the correct location, click the button very slowly. Maybe hold it for minutes or hours?

Might be worth turning off virtual memory? I believe that is an option in all the major OSes, and it can help you budget your memory usage as well as avoid a swap lock-up. Is the underlying problem that your machine has just has too little memory for today’s OS & browser versions? Or you’re visiting a specific web site with a memory abusive app? It sounds here like there are important details you haven’t mentioned yet, not that there is a general problem with browsers necessarily. Yes, browsers and today’s OSes and applications all seem bloated from a user perspective and seem to use enormous amounts of memory. I have run out of RAM before and had to wait for VM swap, and agree it’s very painful. But I haven’t had that happen with a browser in years or maybe ever, and nobody I know is having common browser freezes. Is it worth an SSD & RAM upgraded, might that solve the issue?

It's an 8 GiB machine with an SSD. I open lots of tabs, in lots of browser windows, on lots of virtual desktops, but so what if I do? It's still unacceptable to lock up.

If I visit a specific web site with a memory abusive app, the browser is supposed to protect me. It's the same as any security hole. Malicious web sites aren't supposed to crash my computer.

Yes, I'm still blaming the browser. It's the browser's job to provide protection here. It's a security matter. No matter what my browsing habits may be, letting the computer lock up is not at all OK.

We shouldn't be one bad web site away from swap lock-up.

There is no possible computer upgrade that will fix the issue. There will always be a more-terrible web site waiting to consume all resources.

If it’s unacceptable to lock up, then turn off virtual memory. Swap is not a security hole, it’s a feature doing exactly what it was designed for. Swap is the explicit design tradeoff of the system you bought, and it’s the default behavior because most people prefer that their system work slowly to a system that stops working. Fortunately it’s an optional feature, and you can turn it off.

> I open lots of tabs, in lots of browser windows, on lots of virtual desktops, but so what if I do?

Hehe, the expected outcome of this behavior on an 8 GiB machine with default settings is a slow computer. You can blame the browser and spend your time frustrated if you want to, or you can choose to avoid asking the computer to use 20 GiB and then complain when it swaps, by requesting less memory and/or disabling virtual memory. It’s not that fair to go on and on about some vague abstract idea of malicious web sites and blaming the browser for not protecting you, if you are choosing to open lots of windows, browsers, desktops, tabs, and web sites.

> It’s the browser’s job to provide protection here.

If you study the browser design, and if you compare today’s browsers to those of 5 or 10 years ago, you will find that all the browser devs are actually bending over backwards trying to help you. They’re not perfect, but all of today’s browsers are pretty amazing in how well they handle low resources - but - the browser is just an application that does what it’s asked to do. If you use a web app that consumes 1GiB, the browser tries to accommodate your request. How is it supposed to know you want it to cut off the app instead of do what you asked? What if the app asks for more memory in the middle of what you’re doing, do you want it to lose your work??

The OS is the software locking up your computer, not the browser. Everything you’re talking about can and does happen with regular applications. Even if you got your wish of a browser that protected you from yourself, it wouldn’t solve the problem that landing in swap locks up the machine.

> There is no possible computer upgrade that will fix the issue.

I disagree completely. I never have the problem you’re talking about, and I use dozens and dozens of tabs all day long every day with multiple browsers. $100 in RAM right now could double or triple your capacity, if you don’t want to disable virtual memory nor change your browsing habits.

Yeah there is no solution to fixing the theoretical problem that some software somewhere can ask for more resources than you have. That’s not the issue you brought up though. In practice, the issues you’ve raised about browsing are quite easily fixable.

> browser make a misbehaving site wait

would be a nice operating system feature

Yep. Safari is good, but it's not magic. I suspect psrecord doesn't catch Safari processes because Safari sends them off to launchd because they get launched via XPC, while Chrome's subprocesses are "true" children.

That is correct. I actually spend half a day trying to find a way to get aggregate memory usage of Safari.

You can get most of Safari processes using plain ps as they share the same command:

ps x -o rss,command | grep Safari

There will be a few system threads (for example used for video rendering) that you will have to tie back to one of the processes using launchctl.

Fun fact: activity monitor actually does it through undocumented private APIs as documented here: https://apple.stackexchange.com/questions/327290/how-process...

Hope it saves someone half a day!

The kernel actually keeps track of this information in an internal "responsibility" field for each process. The private API to retrieve this information (which Activity Monitor uses) is responsibility_get_pid_responsible_for_pid, exported from /usr/lib/system/libquarantine.dylib.

That's pretty much what I suspect from those numbers. Safari seems having constant memory usage no matter how many tabs you open. Unless its unloading inactive tabs from ram, there is no way Safari can save ram by using almost 0MB for new tabs.

Can confirm this as a Safari user: old tabs are reloaded sometimes. I guess it's related to memory pressure on the system, seems to be a lot more common on iOS (which of course runs on more RAM-constrained devices).

This is really interesting feedback, but you didn't respond to the Flotato numbers (since this is an ad for their software). Is the dev tricking themselves into thinking they're doing well because they're measuring their own app usage incorrectly?

From what I can tell - yes. Their app uses the standard Safari render processes, so they're only seeing the cost of the main process.

istat menus seems to better report aggregate memory usage. I’m getting 750 mb for Safari on a clean launch with just those two tabs. (It drifts up to 850 mb and back down if I interact with them.)

I was looking at those graphs and thinking exactly that, but that’s a byproduct of google marketing making it sound like chrome is the only browser that does that :D

> I'm somewhat disappointed that the author, or half the comments on the post, didn't question these _wildly_ different results though...

Given that Chrome is busy trying to subsume the web and the OS (it has bluetooth now, and usb, and serial ports, and over a thousand chrome-specific web apis [1]), no one is even remotely surprised to see such results, because by now people just assume Chrome to be a beast. And Chrome has in the past been the most RAM-eating of all browsers out there.

The graphs should be questioned, of course, but Chrome has already earned its reputation, and it's very hard to un-earn it.

[1] https://web-confluence.appspot.com/#!/confluence see "Browser-Specific" tab

This is a bizarre rationalization of a misleading post. So what if Chrome has features, some of which you don't care for? That doesn't make the post right.

he's not rationalizing the original post, he's rationalizing the thread parent's

> half the comments on the post, didn't question these _wildly_ different results though...

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