My Electron application needs a huge amount of memory in the renderer process. Yes, that's intended and no, there's no way around it. (At least none that would make any sense.)
Using performance.memory in the renderer process gives: jsHeapSizeLimit: 3760000000. And I can indeed allocate memory up to about 3.5 GB, then the process will crash.
Now, there's the --max-old-space-size command line parameter to control the available JS heap size of the renderer process in an Electron app. I set it in main.js like this:
app.commandLine.appendSwitch('js-flags', '--max-old-space-size=1024')
Using performance.memory now shows: jsHeapSizeLimit: 1130000000, which is just a little bit more than 1GB, so decreasing the JS heap size works. But I cannot increase it to more than the 3,760,000,000 bytes.
Trying to set it to 8 GB doesn't increase the JS heap size limit:
app.commandLine.appendSwitch('js-flags', '--max-old-space-size=8192')
performance.memory still says: jsHeapSizeLimit: 3760000000
What am I missing? Is max-old-space-size only able to reduce available memory and not to increase it? Or do I have to set another parameter so that the renderer process can utilize the available old space?
The important parts of process.versions:
{
node: '14.16.0',
v8: '8.9.255.24-electron.0',
electron: '12.0.4',
chrome: '89.0.4389.114'
}
This happens on my Macbook with 16GB as well as on my Windows desktop with 64 GB.