Increase Electron Memory limit
Asked Answered
A

1

10

My electron app crashes as soon as the memory usage reaches 2,000 MB.

I can test it by having this code in my main process file which intentionally raises the memory usage:

    const all = [];
    let big = [];
    all.push(big);
    for (let i = 0; i < 2000000000; i++) {
      const newLen = big.push(Math.random());
      if (newLen % 500000 === 0) {
        big = [];
        all.push(big);
        console.log('all.length: ' + all.length);
        console.log('heapTotal: ' + Math.round(process.memoryUsage().heapTotal / 1e6));
      }
    }
    console.log(all.length);

I have tried everything:

require('v8').setFlagsFromString('--max-old-space-size=4096');

app.commandLine.appendSwitch('js-flags', '--max-old-space-size=4096');

But nothing it working...

Tested on electron v3.0.0-beta.12 AND on electron v2.0.9 ~ 2.0.x

How can I increase the memory limit on Electron & not have my app crash as soon as it hits 2GB or RAM usage?

Aspia answered 14/9, 2018 at 18:11 Comment(4)
I would appreciate the same.Heliotropism
It would be great to know this also!Shemeka
Figure this out?Lemming
The renderer process seems to have no such limits. Testing on Win10 I have loaded over 5 hours of high quality audio data via decodeAudioData(), with task manager showing my app is using 6+GB memory, with no issues.Plantation
E
-3

No such problem in electron >8.0.3 (at least). Tested with multiple Buffers, ~2GB each (buffer.constants.MAX_LENGTH)

Englis answered 8/8, 2020 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.