6 ms·
> vast amounts of memory for each tab What underlies this? I am astounded to see 1GB of memory returned when I close a couple of tabs. Chrome and Firefox bot
by JJMcJ 7y ago
> vast amounts of memory for each tab
What underlies this? I am astounded to see 1GB of memory returned when I close a couple of tabs.
Chrome and Firefox both seem like this.
- vaylian 7y agoTo be honest: I do not know. But given how fat most websites are today, I am not that surprised that so much memory is needed. Yes, there is still a major leap from a couple of megabytes to a full gigabyte, but with so many DOM nodes and JS objects I can imagine that even a resource-conservative browser will have trouble keeping memory usage low. Or are there any browsers where you observe significantly less memory usage on the same websites? (Ignoring limited browsers like Lynx of course)
- ygra 7y agoMost modern browsers cache a lot of data in memory as well to make things like navigating back snappy and avoiding a full page re-load. It's also necessary to cache most of the state of the previous page to allow retaining form fields if you accidentally navigated away (as some forms are only in the DOM, created by JS, and not part of the original HTML). I believe to have read somewhere that at least Chrome listens to low-memory situations broadcast by the OS and will evict such caches. So while it uses a lot of memory as long as memory is available, it will also release much of it if necessary.
- PeCaN 7y agoThis makes sense but is somewhat annoying since a web browser is not the only program running on my computer (but apparently wants to be) and eats up RAM that could be used for the OS file cache. I wish there was some sort of allocation API specifically for allocating caches so that recently accessed files could kick out a web browser's cache of a not-so-recently accessed tab or vice versa.
- deleted 7y ago[deleted]
- nitrogen 7y agoPOSIX does have something sort of like this in madvise(), but I couldn't find a specific option for the semantics you described.
- bjoli 7y agoOn a low memory computer I had configured FF to not show images unless I alt-clicked them. Together with not using JavaScript this meant using significantly less memory. I suspect browsers still have to have raw bitmaps in memory, which for the 2mb jpegs you are fed everywhere quickly adds up...
- chmod775 7y agoThey have to be in memory somewhere. They technically don't have to be kept in RAM if they are uploaded to VRAM though. Assumining RGBA it's just over 8MB for a 1920x1080 image.
- gnode 7y agoImages could be kept compressed until they are painted. Most GPUs support texture compression, so don't need to keep a bitmap for compositing.
- chmod775 7y agoTexture compression is inherently lossy, so it isn't an option. It's also really dependend on your textures and what you want to do with them, you don't want browser to just go give it their best shot at compressing your company logo.
- plasticchris 7y agoJavascript? I use noscript and it's less than 200MB/tab, even with major news sites and what not open.
- ryandrake 7y agoAnswer is too simple. Exactly what is taking up what memory? I'd love to see the annotated memory map of these processes. M Kb of javascript text. N MB of image data, O MB of this, P MB of that. Unpopular opinion time: My guess is most developers don't care and are not even looking at this anymore, either during development or after release. Nobody seems to even know how much memory their program allocates and how quickly it allocates that memory under various running conditions. I used to challenge my fellow developers: Stop in the debugger right now. About how much memory should the process be using? Nobody even seems to have an order-of-magnitude guess anymore. It's your program, dude! Shouldn't you know this? You can ask any embedded software engineer exactly how much memory his/her program uses, what's the stack size, what's the heap size, what's statically and dynamically allocated. Sadly, this discipline is pretty much gone outside of that specialized area.
- voltagex_ 7y agoChrome: https://developers.google.com/web/tools/chrome-devtools/memory-problems/allocation-profiler https://developers.google.com/web/tools/chrome-devtools/memo... Firefox: https://developer.mozilla.org/en-US/docs/Tools/Memory https://developer.mozilla.org/en-US/docs/Tools/Memory
- CJefferson 7y agoFor browsers, this problem is "once removed". Firefox and Chrome both go to heroic efforts to reduce memory usage. However, given the html and javascript which fill most websites, and users expecting responsiveness, it turns out to be very hard to use less memory.
- agent008t 7y ago200MB/tab just to display some text with markdown and maybe some small images? Isn't that insane?
- lanevorockz 7y agoBrowsers are little OSes with encapsulated virtual machines. As every website tends to be a mix of web trackers, ads, server dependent functionality. The whole thing can be a big mess.
- iamnotacrook 7y agoYou want your browser to be fast. Browsers are often the only thing running. You have a bunch of ram. Unused ram is pointless. Disks are large and fast and are used for swap. It's not clear why you're suprised, what the problem is, or why anyone would put any effort into optimising a browser for memory usage. The number of people who have tens or hundreds of tabs open in the real world isn't as large as it is on HN and other tech sites, and for many people who do just keeping the url around so the site can be reloaded is probably good enough.
- rat9988 7y ago> Browsers are often the only thing running. If I had to choose one program that is proportionally used the least alone, I would have voted browsers.
- _-___________-_ 7y ago1 GiB of virtual memory, I assume. IOW, not the same thing as 1/32 of your 32 GiB of RAM, for example.
- jamienicol 7y agoIt's spread across all parts of the browser, but speaking as a Firefox graphics engineer, we use quite a lot of memory. Painting web pages can be slow, so we try to cache as much as possible. When elements scroll separately, or can be animated, we need to cache them in separate buffers. If we get the heuristics wrong (and it's hard to get it right for every web page out there) this can be explosive. It's not helped by the fact that graphics drivers can frequently bring down the whole process when they run out of memory. It's a hard problem, but webrender will help as it needs to cache less.
- heavenlyblue 7y agoSo let's say I'd like to write a memory-efficient web page, what should I avoid then?
- Crinus 7y agoHTML3+
- na85 7y agoJavaScript
- heavenlyblue 7y agoIs that a joke, or are you essentially saying that if I used WebAssembly, then most of the memory usage would go down?
- superkuh 7y agoHe's not wrong. If you disable JS by default tabs will take much, much less RAM. Sites that require JS aren't worth the time anyway. Unless you're literally writing an application there's no reason to require executing code to render in text and images. And there's absolutely no reason to not have a no-JS fallback. In fact, there should be a real HTML skeleton first upon which you write JS enhancements. But these are all things you do if you want to make a webpage for people. If your main concern is corporate profit or saving institutional funds then SPAs and requiring JS for obfuscation makes sense in the anti-user way that corps trend to. It's just faster. Who cares if it's anti-user when profits are on the line?
- tempguy9999 7y agoIf it helps any I have ~2500 tabs open in palemoon (well overdue for an afternoon of tab culling but anyway) and it's ~1.5GB. I never allow JS. So my guess is it's either JS directly, or perhaps JS pulling in extra resources when allowed to run.
- michaelmrose 7y agoI think a personal wiki with clickable links to 2500 sites would be more useful than a browser with 2500 tabs open. It could even be easily curated by more than one person. That said, Firefox some strides starting in 55 insofar as handling very large number of tabs starting in version 55. https://www.techradar.com/news/firefoxs-blazing-speed-with-huge-numbers-of-tabs-leaves-chrome-in-the-dust https://www.techradar.com/news/firefoxs-blazing-speed-with-h... Unfortunately Palemoon is more or less firefox 38 still isn't it?
- tempguy9999 7y agoJust tidying up after myself would fix most of that. I don't know what palemoon~firefox relationship is versionwise. But my point was more that sans JS it really seems to use up far less memory. Honestly, try nuking js for 1/2 hour and see how it feels.
- michaelmrose 7y agoI get annoyed at all the sites that don't work without js. My most common scenario with js is 10 tabs using 400Mb of ram to 30 tabs using less than 1gb with the former scenario being more common.