Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Node application crashes with std::bad_alloc while refusing to consume more memory than 18GB of memory

I have a node application which produces the following error

$ export NODE_OPTIONS=--max_old_space_size=24000
$ time npm run build
...
terminate called after throwing an instance of 'std::bad_alloc'
...

No further information is given on the console. I have some heap dumps, but I'm not sure if they are complete.

The strange thing to me is that this happens very consistenly at around the same time, and (looking at memory usage through htop) happens very consistently around 18GB of memory usage. But as far as i can tell I have told npm it can use more than 18GB.

I have 32GB om memory on my machine. My machine doesn't even start swapping before the node app crashes. The way I see it, there is still memory to consume, I have told node that it can consume more memory, and yet it refuses.

I have also tried setting it to something much higher like 51GB, I have a swap partition which is also 32GB. The exact same thing happens, the app crasches at 18GB of consumed memory.

I have looked at the ulimit's, but those seem fine:

$ ulimit -m
unlimited

$ ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 127351
max locked memory           (kbytes, -l) 64
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1024
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 127351
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

Is there some other reason node will refuse to consumer more memory?

Perhaps it is not relevant but this is a gatsby build, I have tried to add --inspect to the NODE_OPTIONS, but I get the impression that I'm connecting to some 'management' process and no the process that actually goes out of memomry, (if i'm correct gatsby will spawn new child processos to do the actual build).

For what it is worth, some extra info:

$ npm -v
7.20.6

$ node -v
v14.17.4
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!