Electron fails to allocate buffers bigger than 2GB?

#1

Hello,

Long story short, I’m using an external library that needs to make an initial bulk allocation of about 3GB, using Electron 5.0.1.
While multiple 1GB allocations are not problematic, a single big allocation crash the application:

[9201:0514/170306.300306:FATAL:memory_linux.cc(42)] Out of memory.

I’m using Electron 5.0.1 (but I tried also older versions). In my system I can test this already simply adding:

Buffer.alloc( Math.pow(2,31) - 1, '0');

This does not happen with bare node.js.
I tried also:

  • setting the env var ELECTRON_RUN_AS_NODE
  • setting the env var NODE_OPTIONS=--max_old_space_size=8192
  • passing the cli option --args --js-flags='--max_old_space_size=8192'

Is there a reason for this? Can the behaviour be bypassed?

Any help will be highly appreciated.

Best Regards.