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

114
Visualizações
Why cannot v8/nodejs allocate a max-size array if sufficient memory?

I'm aware the maximum length of a JavaScript array is 2^32-1, but regardless of how much memory I permit it will still fail to allocate. What's going on? One-line repro:

node --max-old-space-size=100000 -e "console.log(v8.getHeapStatistics().total_available_size);Array.from({ length: Math.pow(2, 32)-1 })"

For clarity the above example exposes 100GB to v8, which is confirmed via total_available_size. 8GB might be sufficient for testing this operation since most people won't have 100GB, but it'll fail regardless. Is this a bug in V8?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

(V8 developer here.)

No, it's not a bug, just an implementation-defined limit. V8 has an internal limit of ~1GB for any individual heap object. At 4 bytes (with pointer compression) per element, that means a maximum of ~256M elements per array.

There are plenty of other implementation-defined limits, e.g. for TypedArray length, string length, BigInt size, recursion depth, number of parameters per function, number of entries in a Map, etc. Pretty much everything has a limit, even if the JavaScript spec doesn't mention it explicitly, or mentions a theoretical limit that's different from implementation limits (which are implicitly assumed to exist).

over 4 years ago · Santiago Trujillo Relatório
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