Inconsistent amount of processes


#1

Hello.

I am trying to build an Electron application and currently I am exploring quick start example from the GitHub repository (https://github.com/electron/electron-quick-start), running on Electron 4.0.7 prebuilt binaries files for Windows x64.

Whenever I start the application Task Manager displays different amount of processes and CPU usage.
For example: sometimes application runs as 2 processes and uses about 10% of CPU power.
However, in other cases application uses about 20% and runs as 3 processes.

electronissue

Can I somehow affect or limit amount of processes spawned by the application?

Thanks in advance!


#2

Electron spawns new processes pretty regularly, just like its parents: Node.js and Chrome. The only real way to limit your processes is to not do things that require new processes be made. You’re going to have two by default (renderer and main), and you could pick up quite a few more if you want your app to do a lot of things like Atom does. I have two Atom windows open and see eight processes.

Don’t fear the process. Yes, try to make your app work as efficiently as possible, but understand that you’ve got a jet engine (Node) bolted to a schoolbus (Chrome) and so your baby is never going to be as sleek and efficiently performant as those programs built in C and Java and lovingly optimized for machine code. Processes are valuable in this software space because JavaScript sucks ass at multitasking or doing anything timed, and when browsers store all the web pages you ever look at in one process you could end up with a heinous memory leak, or something like that. New processes get spun up to handle new problems, and when they’re done they should go away. If you use the Node and Chrome features correctly, you should be fine.


#3

Many thanks for the answer! I now have read a bit more Electron architechture related articles and now I understand how it works better :slight_smile:

The problem in my topic, however, was not the inconsistent amount of processes spawned, but incorrect information displayed by Task Manager.

There is always a certain number of processes but sometimes one process is displayed as ungrouped and listed in Background processes tab.