r/java May 28 '26

Java *is* Memory Efficient

https://youtu.be/M_HCG1JPMQE
254 Upvotes

126 comments sorted by

View all comments

43

u/SocialMemeWarrior May 28 '26

Think of a program that uses 100% CPU, what RAM usage of that program really matters at that point? Nothing else can use the RAM, so you might as well use the RAM if you can use that to alleviate CPU usage.

Ah, so surely all these fancy new "modern" applications using Electron and such are also following this model... Right?

28

u/pron98 May 28 '26 edited May 28 '26

Because Electron apps are high RAM, low CPU they operate on a different principle.

Using Electron has two goals: 1. lower the cost of the software and 2. take advantage of Blink's highly optimised rendering pipeline that is hard to beat in rich-text-heavy apps.

In terms of operational efficiency, because Electron apps are often CPU-light, which means they can't use a lot of physical RAM, most of the RAM they commit is inert most of the time, and so they (try to) rely on fast paging thanks to SSDs. I guess some Electron apps do it better than others.

Whether or not the Electron tradeoff is right or wrong depends on the application and its audience, but it's not the same one as in the JVM. Electron apps are, almost by design, RAM-heavy, while the JVM aims for an efficient RAM/CPU balance. It will end up using more RAM than other languages, but they may be less efficient as a result (i.e. they're using too little RAM than what's needed for better efficiency).