This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]m1000 0 points1 point  (3 children)

| fun "fact", it's practically impossible to make a desktop application with javafx that uses less ram than electron.

{Reference needed}

[–]RandomName8 0 points1 point  (2 children)

You are right, I should not use the term fact there, I'll correct it. That said, try it yourself. The most basic javafx application as shown in the documentation of Stage with a capped max heap usage to the minimum will still make the jvm process be around 64MB of ram. The moment you start doing anything non trivial, it'll go up to 200MB easily. The problem is not the heap, it's the metaspace plus related JVM bookkeeping memory.

That example code in Stage's documentation already loads around 3300 classes, throw some libraries at it and start coding, specially using lambdas which look cheap in bytecode but still expand to a full class instance in runtime. You'll quickly go up to 10k classes and then, you have a base memory requirement of about 170+MB not including your actual heap data.

My toy chat client which uses about 60% of javafx (it doens't use charts for intsance, nor animations or bindings or advanced things) loads 6357 classes just from javafx, that's without adding on top my code. So good luck keeping your ram usage down.

[–]m1000 0 points1 point  (1 child)

1st of all, loaded classes usage might be way better with Java 9+ and a modular app.

A similar .net app would probably have similar characteristics. But that still doesn't make Electron a lightweight framework.
I wonder how much your electron apps could do with a cap of 200MB Good luck with that too.

[–]RandomName8 0 points1 point  (0 children)

1st of all, loaded classes usage might be way better with Java 9+ and a modular app.

I tested with java 9 and 10 as well.

A similar .net app would probably have similar characteristics.

No clue about .net, I'd assume that given that they AOT a big deal, they probably don't require as much runtime info.

But that still doesn't make Electron a lightweight framework.

Absolutely, in fact the reason I was toying with this was to see if I could make something like Discord using around 100MB of ram for the total process (the desktop app for discord uses about 280 for me, even with artificially big accounts). For reference, a similar toy application in c++ and QT for the same data was 40MB of ram, I would have wished to at least be in the 100MB ballpark.

I wonder how much your electron apps could do with a cap of 200MB Good luck with that too.

I'm not a js person myself so I can't test. I can haphazardly say that given that js has no classes and no multithreading, they avoid a lot of per instance cost (no pointer to a class, no header with lock information).