News for hackers. Stuff that matters.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by efdee on Wednesday February 26, 2020 @11:12AM (#22424258)
Where 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.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by csnover on Wednesday February 26, 2020 @11:34AM (#22424512)
I’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.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by lucsky on Wednesday February 26, 2020 @01:51PM (#22425939)
I wish this urban legend would just stop: the Spotify desktop client is NOT an Electron app, it's a CEF (Chromium Embedded Framework) app.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by thatsnotmepls on Wednesday February 26, 2020 @01:57PM (#22425997)
Well, it runs an instance of Chromium. So basically the same thing in this context.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by tsukurimashou on Thursday February 27, 2020 @04:08AM (#22431792)
seems like the same shit to me, uses a lot of RAM, lags randomly, yup I usually call that electron :>
Re:NeutralinoJS: Lightweight Electron alternative using nati... by pjmlp on Thursday February 27, 2020 @12:14PM (#22435262)
Same thing, just another name.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by fmakunbound on Wednesday February 26, 2020 @12:20PM (#22425031)
Wow. I've got Apple Music/iTunes running for a week or so on this Catalina macOS and the process viewer reports 300MB (including sub-processes). I assume it's a native application. How does Spotify manage to use so much RAM??
Re:NeutralinoJS: Lightweight Electron alternative using nati... by kitsunesoba on Wednesday February 26, 2020 @01:19PM (#22425652)
The Spotify desktop client is architected such that each pane in the main window is essentially its own separate webapp, complete with duplicate (and triplicate, quadruplicate, etc) dependencies. They did this so their various teams don’t have to talk to each other.

Desktop Spotify has been a resource hungry mess for years now. It used to be known for prematurely wearing out SSDs by constantly writing stuff (cache I think?) to disk.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by csnover on Wednesday February 26, 2020 @01:35PM (#22425788)
> It used to be known for prematurely wearing out SSDs by constantly writing stuff (cache I think?) to disk.

They were constantly vacuuming some SQLite database.[0]

[0] https://arstechnica.com/information-technology/2016/11/for-f...

Re:NeutralinoJS: Lightweight Electron alternative using nati... by felubra on Wednesday February 26, 2020 @03:27PM (#22426952)
Does anybody know if this was fixed?
Re:NeutralinoJS: Lightweight Electron alternative using nati... by montag on Thursday February 27, 2020 @04:10AM (#22431801)
Yes, it was.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by atombender on Wednesday February 26, 2020 @01:42PM (#22425852)
They also have this problem where a "Spotify Helper" can crash constantly, and you won't notice it unless you look at the process tree.

On macOS, this will start a ReportCrash process, and end up taking up an entire CPU core just repeatedly crashing, reporting a crash, restarting, etc. It also significantly impacts battery life.

This happens every day for me. It's arguably worse than the SSD-killing SQLite vacuum problem they had.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by derefr on Wednesday February 26, 2020 @06:41PM (#22428751)
I haven't seen this one personally, but I get the same crash-loop from the Discord app.

Weirdly enough, the crashes don't seem to affect any of the app's functionality.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by ajxs on Wednesday February 26, 2020 @04:40PM (#22427651)
> They did this so their various teams don’t have to talk to each other.

This is absolutely dreadful. I've unfortunately worked in multiple organisations where teams deconstructed their web-based products into microservices for this very reason.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by city41 on Wednesday February 26, 2020 @11:02PM (#22430324)
I have found it to be rather buggy. I sometimes can't get songs to play, and other times can't get them to pause :) I switched to using their web interface in Firefox which has been totally rock solid.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by fmakunbound on Friday February 28, 2020 @01:45AM (#22440985)
> They did this so their various teams don’t have to talk to each other.

This is just insane.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by hnuser123456 on Wednesday February 26, 2020 @12:46PM (#22425303)
Keybase also uses in the range of 600MB-1GB, and 8 processes, most of which don't exit when you exit the application. I'm not sure what Discord uses because I only run it in the browser, but I'm sure it's in the same range as all of the above.

I've come up with a powershell snippet to fully quit keybase and reclaim ~1GB RAM:

get-process | Where-Object {$_.path -match "keybase"} | Stop-Process

Re:NeutralinoJS: Lightweight Electron alternative using nati... by andai on Wednesday February 26, 2020 @03:00PM (#22426703)
>I'm not sure what Discord uses because I only run it in the browser

Me too, and you just made me realize, there already exists a system for running Electron apps in a shared instance of Chrome, and it's installed on almost everyone's computer! You just... open the web version, in Chrome :)

Re:NeutralinoJS: Lightweight Electron alternative using nati... by derefr on Wednesday February 26, 2020 @06:46PM (#22428799)
Mind you, there's (sometimes a little, sometimes a lot) more to Electron than a webview. Some apps are running quite a bit of un-sandboxed native code—sometimes even forking off other native processes†—to do what they do. Keybase is, IIRC, one of the apps that are quite large on the "native" side.

† I once designed a system that has Electron install an Erlang release to the client, register it as a service, and start it. The Erlang node runs a locally-bound web server; the Electron app then visits that web server. All the data-wrangling happens in Erlang land, with Electron just serving as an HTML renderer for the pages coming from the local server. And yet Electron's native side is essential, here, because it ultimately manages the Erlang release (installing it, updating it, etc.) Erlang doesn't have any good tooling for doing client-native stuff on its own; Erlang devs find the whole idea of deploying an Erlang release to a client machine funny.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by dnautics on Wednesday February 26, 2020 @08:09PM (#22429371)
That's fantastic. I wonder if an elixir Phoenix / liveview use case with such a setup is reasonable now that elixir has releases. I think client native nifs are also not out of the question with the better tooling that comes out of modern langs like rust, nim, and my favorite zig.
Re:NeutralinoJS: Lightweight Electron alternative using nati... by tsukurimashou on Thursday February 27, 2020 @04:10AM (#22431803)
The irony about that, is that not all electron apps are available from an URL. (now I know there is more than a webpage in a electron app, but with modern browsers you can have the same experience in a electron app or from a webapp pretty easily)
Re:NeutralinoJS: Lightweight Electron alternative using nati... by ygra on Wednesday February 26, 2020 @05:10PM (#22427935)
The shorter form, before people complain again that PowerShell is too verbose:

   gps | ? path -m keybase | kill
Re:NeutralinoJS: Lightweight Electron alternative using nati... by dsissitka on Wednesday February 26, 2020 @04:55PM (#22427789)
Discord seems surprisingly efficient for an Electron app.

https://imgur.com/a/DJKyyRz

That's ~230 MB. I can get it up to ~275 MB but it seems to return to normal pretty quickly.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by bufferoverflow on Thursday February 27, 2020 @06:28PM (#22439070)
I have VSCode running and it takes up only 166MB or RAM.

Proof: https://i.imgur.com/nKenjcw.png

Re:NeutralinoJS: Lightweight Electron alternative using nati... by gridlockd on Wednesday February 26, 2020 @12:07PM (#22424910)
Over here, the base overhead of an Electron window is around 60MB. How do you know it's not those applications allocating a lot of memory that is causing all this usage?
Re:NeutralinoJS: Lightweight Electron alternative using nati... by csnover on Wednesday February 26, 2020 @01:45PM (#22425876)
Of course I don’t know that since I don’t have the time or ability to inspect what the apps are doing. :-) The best I can do is give comparisons to the old non-Electron versions of Spotify and Skype, which had all the same core features as the Electron versions and used less memory for the whole app than you’re saying a base Electron window costs.

It is difficult for me to lay blame at the feet of application developers (assuming they didn’t make the choice to use Electron) when the platform itself is so bad at giving developers ways to manage their apps’ memory usage.

If you want to listen for an event on a global object like `window`, the platform could give a way to do this using a weak reference, but it doesn’t, so you have to make sure to always remember to manually remove the listener yourself or else you’ve just leaked a bunch of stuff.

If you want to load an image, or some other media, the platform could give a way to control the runtime’s internal caches so you aren’t retaining data in memory that you don’t need—but it doesn’t, so you have to hope that the generic runtime memory cache from Chromium is intelligent enough not to retain unimportant things (and, in my experience, it’s not).

This problem has existed in one form or another in every Electron app I’ve ever used. Some are certainly worse than others, but I don’t think I’ve ever seen one come within even an order of magnitude of the memory usage of similar apps written natively.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by filleduchaos on Wednesday February 26, 2020 @12:19PM (#22425022)
What's the uptime on that "base application" and what does it do?
Re:NeutralinoJS: Lightweight Electron alternative using nati... by judge2020 on Wednesday February 26, 2020 @12:31PM (#22425149)
Re:NeutralinoJS: Lightweight Electron alternative using nati... by filleduchaos on Wednesday February 26, 2020 @03:21PM (#22426900)
So an "application" that literally just displays Hello World and no indication of uptime.

Right, I'm convinced.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by bavell on Wednesday February 26, 2020 @03:42PM (#22427101)
It shows that the framework itself only uses 60MB and implies any higher usage is due to the application built on top of electron. I'm not sure why uptime matters unless you're assuming there are memory leaks?
Re:NeutralinoJS: Lightweight Electron alternative using nati... by derefr on Wednesday February 26, 2020 @06:36PM (#22428707)
The context here is that "the framework" does things 'for' the application it is hosting that the application cannot control, caching various things in memory in a way that makes sense for a browser, but not very much sense for a custom application.

Try this: open a new Chrome instance; look at its memory usage; then load a bunch of tabs (try an Open All on a bookmarks folder), close them all again, and then look at Chrome's memory usage again. It will have increased.

Chrome isn't leaking memory; instead, it is doing the same thing that an Operating System does: weakly reserving memory to optimistically cache stuff, releasing it again if there's enough memory pressure.

This works okay if you only have Chrome itself running. (Even then, its cache fights a bit with the OS page cache. It's certainly no Postgres, intentionally getting the OS page-cache to do its caching for it.) But as soon as you have two separate Chromium instances running (e.g. Chrome itself, plus an Electron app), then each one is going to try to "optimistically" cache as much stuff as it can, until it runs into the memory pressure created by the other instance caching as much stuff as it can, and so each instance will unload just a bit to let the other one cache just a bit more—back and forth—forever. Together, they thrash memory, and it becomes much harder for them to actually accomplish the "weak" part of "weak reservation", instead ending up hoarding all the memory between them.

This is the pretty much the same problem you see if you try to e.g. run two memory-heavy JVM processes (e.g. ElasticSearch) on the same system. Chrome is just one of the few times you'll see this "recapitulation of memory management within the runtime" effect client-side, rather than server-side.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by bavell on Friday February 28, 2020 @10:19PM (#22448539)
Great points, thank you!
Re:NeutralinoJS: Lightweight Electron alternative using nati... by filleduchaos on Wednesday February 26, 2020 @07:14PM (#22428990)
What derefr said about Chrome holding on to memory, and additionally memory leaks are absolutely a concern for related reasons.

(Regarding uptime, it's not at all uncommon for Chrome's memory usage to double or even triple overnight. Partially a function of the websites you have open, sure, but also partially a function of Chrome itself).

Re:NeutralinoJS: Lightweight Electron alternative using nati... by derefr on Wednesday February 26, 2020 @11:34AM (#22424504)
What’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.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by dreamcompiler on Wednesday February 26, 2020 @07:08PM (#22428949)
They 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.

Re:NeutralinoJS: Lightweight Electron alternative using nati... by efdee on Wednesday February 26, 2020 @01:30PM (#22425751)
Multiple weeks of uptime (on a laptop that is used daily and hibernates at night).
Re:NeutralinoJS: Lightweight Electron alternative using nati... by rco8786 on Wednesday February 26, 2020 @12:08PM (#22424921)
Currently Slack is taking ~1.2GB on my laptop
Re:NeutralinoJS: Lightweight Electron alternative using nati... by colejohnson66 on Wednesday February 26, 2020 @11:16AM (#22424303)
I’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-...

[1]: https://stackoverflow.com/questions/53658769/why-vscode-requ...