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

70
Views
El bucle `for` anidado en una gran variedad de objetos está creando una fuga de memoria

Estoy tratando de analizar más de 100k objetos en una matriz para encontrar patrones. Construí un nido para que el bucle se ejecutara sobre todos los elementos de la matriz.

 // const allPairs = [...] array with more than 100k objects const patterns = []; for (let i = -5; i < 5; i++) { for (let j = -5; j < 5; j++) { for (let k = -5; k < 5; k++) { for (let l = -20; l < 20; l++) { patterns.push({ pairs: allPairs.filter((pair) => { return ( pair.varA > pair.value * i && pair.varB > pair.value * j && pair.varC > pair.value * k && pair.average > l ); }), name: `Pattern A ${l}-${i}-${j}-${k}`, }); patterns.push({ pairs: allPairs.filter((pair) => { return ( pair.varA < pair.value * i && pair.varB < pair.value * j && pair.varC < pair.value * k && pair.average < l ); }), name: `Pattern B ${l}-${i}-${j}-${k}`, }); } } } }

Básicamente, estoy tratando de filtrar mi matriz para encontrar qué patrón tiene más objetos.

Esto siempre está generando. FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Intenté aumentar la export NODE_OPTIONS="--max-old-space-size=5120" pero también falla.

Los objetos se ven así

 { id: 111339, symbol: 'HELLO', tested: true, successful: false, average: 0.010298, value: 1.4, varA: 0.51118, varB: -0.1545, varC: -0.1547, varD: -0.3592, varE: 0.51118, varF: -0.1545, varG: -0.1547, varH: -0.3592, varI: 0.51118, varJ: -0.1545, createdAt: 2022-06-10T15:30:09.170Z, updatedAt: 2022-06-10T16:29:08.324Z }

¿Alguna recomendación para hacer esto más eficiente?

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!