Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda