Skip to content
RED SAGSkills
hard20 pts · first answer countsjavascriptclosuresmemory

Closure holding a big array

A page memory grows steadily. Why might this handler keep a 50 MB array in memory after setup() finishes?

function setup() {
  const report = loadHugeReport() // 50 MB array
  const total = report.length
  button.addEventListener("click", () => {
    console.log(report[0], total)
  })
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions