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?

Rayan Salhab
  • 131
  • 8

1 Answers1

-3

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

sanperrier
  • 606
  • 5
  • 12