8 ms·
I feel like nobody cares too much if they’re running one Electron app; people do have the headroom for an extra 1-2GB of RAM usage. The problem comes when they
by derefr 7y ago
I feel like nobody cares too much if they’re running one Electron app; people do have the headroom for an extra 1-2GB of RAM usage. The problem comes when they run several Electron apps at once, and each comes with its own “base” overhead (i.e. the runtime memory consumption of the browser-runtime as a whole, independent of how many render contexts are open.)
Chromium is built to share a lot of things between tabs efficiently, but this economy-of-scale doesn’t translate over into having multiple instances of Chromium running. Each instance gets its own GPU renderer process + font-glyph tile cache, its own network-request cache (i.e. its own in-memory key-value store with its own LRU limit), etc. Running multiple Chromium instances at once is a bit like running multiple copies of an RDBMS on the same machine and expecting them to not fight over memory.
Does anyone know what exactly this “base” overhead in Chromium consists of; and, more importantly, how often it changes relative to Chromium releases? Because I’m wondering whether it’d be possible to factor most of it out into a separate layer from the highly-iterated-on “browser engine” DLL stuff (the renderer + DOM + JS layer) into its own sort of “Chromium Core Services” DLL, which could be relatively-more ABI-stable.
If you had that factoring-out, you could achieve a pretty good memory + CPU savings just by having Chromium + application frameworks like Electron all share one copy of the Chromium Core Services between them, while keeping their own higher-level “renderer+VM” DLL on top (which would hopefully be pretty stateless in terms of shared state, only adding the ~50MB mmap(2) overhead of the DLL-image itself, and then whatever memory the individual render-contexts consume.)
Alternately, of course, you could build Electron as a pseudo-browser where Electron “apps” are just separate windows running in its memory space, and the native Node processes are all just distinct V8 Execution Contexts in the same process. But 1. this would lose you the ability to develop for a particular version of the renderer, which is what Electron gains you over projects like Neutralino in the first place; and 2. this wouldn’t give you the benefit of Electron sharing service-memory with Chrome itself.
- efdee 7y agoWhere is this 1-2GB number coming from? I'm running a fairly large Electron app and the combined memory usage of its processes is about 250-300MB.
- colejohnson66 7y agoI’m spitballing, but Chrome does have issues with high memory usage[0]. But also, VS Code can take up multiple gigabytes[1] on a large project. [0]: https://lifehacker.com/why-chrome-uses-so-much-freaking-ram-1702537477 https://lifehacker.com/why-chrome-uses-so-much-freaking-ram-... [1]: https://stackoverflow.com/questions/53658769/why-vscode-require-so-much-memory-how-to-make-it-more-clean https://stackoverflow.com/questions/53658769/why-vscode-requ...
- derefr 7y agoWhat’s its uptime? A lot of Electron apps—even ones that use minimal local JS, serving mostly as a webview—accrue base overhead as you use them, then keep it around even when you close their main window (and thus release their main Chromium-side render context), as long as the process stays alive. They’re caching stuff (like, as I said, rendered font glyphs, or network responses.) I have a copy of Slack running that’s using 2GB right now, with no window open.
- efdee 7y agoMultiple weeks of uptime (on a laptop that is used daily and hibernates at night).
- dreamcompiler 7y agoThey might call this "caching" but it's still a memory leak. Over time, the application consumes increasing amounts of a finite global resource while not appreciably advancing its own progress, and negatively affecting the whole system. That's a memory leak. The solution is for operating systems to inject deliberate back pressure on memory allocations for user-selectable applications to stop them from behaving this way. "No memory for you. Try mallocing smaller chunk. Maybe I grant; maybe I don't. Maybe I just kill -9 you if you bug me too much." This is exactly how I wish my OS would treat web browsers.
- csnover 7y agoI’m currently running three Electron apps: Spotify, Skype, and VS Code. Spotify: 1083.7 MB. VS Code: 890.9 MB. Skype: 406 MB. In the past, I’ve had projects open in VS Code which have caused that number to shoot up into the multi-gigabyte range. Of course this is all anecdotal but I am pretty sure these numbers come from actual experiences that people are having with Electron apps.
- woodrowbarlow 7y agoi believe (but may be mistaken) that this was a goal of mozilla's positron project -- an electron-compatible runtime that uses firefox instead of chromium, but shares most resources across all of the positron apps running on your system so that it's more like having multiple tabs open rather than having multiple distinct instances open.
- smt88 7y agoThis paradigm is already supported by Container Tabs. It seems like Firefox is really close to the ideal of sharing memory without sharing user data.
- NullPrefix 7y agoThere's Carlo [1], which is an alternative to Electron that uses locally installed Chrome. 1: https://github.com/GoogleChromeLabs/carlo https://github.com/GoogleChromeLabs/carlo
- mfer 7y agoThe problem with this is that is requires people to have Chrome installed. That's a awkward dependency to require for a stand alone app.
- NullPrefix 7y agoFound this in Carlo to issue 90 [2]: >If one chooses a chromium channel in the launch options, then carlo calls puppeteer createBrowserFetcher which will download the chromium revision compatible with Puppeteer or even a specific revision. sunglasses In regular ElectronJS you have the same Chromium bundled with the app. Not sure if puppeteer installs a local or system wide Chromium. 2: https://github.com/GoogleChromeLabs/carlo/issues/90 https://github.com/GoogleChromeLabs/carlo/issues/90
- petecox 7y agoWindows 10 (Edge), Chrome OS and Android all now bundle Chromium, while it's packaged in desktop Linux. That really leaves only macos. VSCode, say, as a slimmer download sans web runtime is a possible outcome.
- potiuper 7y ago"While it's packaged in desktop Linux" you are using the wrong distro(s).
- tln 7y agoAnd node!
- zelly 7y agoGiven that everyone brings this up every time Electron is mentioned, and Electron apps keep proliferating, I expect a future version of Windows and macOS to have Chromium bundled with the OS. There will be some platform independent open standard that Electron will use under the covers. Native desktop apps are never coming back. It will either be Electron or mobile apps emulated on desktops.
- ArtifTh 7y agoCurrent version of Windows already have Chromium in the form of new Edge and Microsoft seems to start pushing progressive web applications. At least they made good integration with system for them. So, perhaps, soon we will have PWAs instead of bunch of electron apps each carrying its own Chromium.
- zelly 7y agoPWAs can never fully substitute native applications. It's difficult to access hardware and impossible to call operating system functions from a PWA. Applications that do something interesting tend to have a native library behind the frontend that does performance-sensitive work.
- pjmlp 7y agoQuite the contrary, one of the benefits of PWAs is exactly that when they are distributed via app stores they get access to native APIs without any kind of manual FFI. That is how they work across ChromeOS, Android and Windows, with Apple being the outlier for obvious reasons.
- zelly 7y agoI didn't know this. If this is true then it's more powerful than Electron, which requires you exchange IPC messages from a separate process. The fact that you have to use the app store is a major disadvantage though.
- kaishin 7y ago
- dmitrygr 7y ago> I’m wondering whether it’d be possible to factor most of it out into a separate layer We've done this. The layer is called a web browser. You deliver runnable code to it using something called HTTP.
- meesles 7y agoDid you even read the comment? GP literally addresses deficiencies in this layer when running multiple instances of the browser.
- dmitrygr 7y agoi did, and found them unconvincing > 1. this would lose you the ability to develop for a particular version of the renderer html and css are standards, if you are developing for a version, you are wrong. full stop. > 2. this wouldn’t give you the benefit of Electron sharing service-memory with Chrome itself there would be no electron so point is irrelevant
- derefr 7y ago> html and css are standards, if you are developing for a version, you are wrong. full stop. Who said anything about HTML and CSS? Apps like VS Code create and manipulate a DOM directly in JS, or more often these days, WASM. To these apps, Electron is just a virtual machine with a lot of browser-like multimedia APIs attached. You pin the exact version of the renderer just like you pin the exact version of your dependencies in a server-side app, or the exact version of the OS in a virtual-appliance VM image. Electron has nothing to do with "the web" or "web standards" other than borrowing technologies originally developed for those. Electron competes with things like Unity and https://love2d.org/ https://love2d.org/, not with browsers. It's in a category of frameworks with the goal of giving the developer pixel-perfect control over what the user sees, where apps are separately developed, tested, and tweaked, for each target (e.g. each OS, each kind of display/interaction methodology, etc.) With this category of framework, you don't build your app as generic code targeting a standard; rather, you build, and test, your product against a specific "engine." (Imagine for a moment that people could take Unity apps and run them against any old version of the Unity engine, or even against Amazon's Lumberyard fork of the same. Would anything work?)
- jcelerier 7y ago> Chromium is built to share a lot of things between tabs efficiently yey, currently using 6.6 gigabytes on my machine (RSS)... efficient... firefox is no better, sitting at 4.8 gigabytes...
- ljm 7y agoIt has side effects, too. For example, I wanted to record a new screencast with OBS Studio (fantastic free software), but couldn’t capture any chromium-based application without disabling GPU-acceleration. Only happens with electron apps.