Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
How does memory leak happen from arrow functions

I have two methods below:

function foobar() {
   const viewState = getViewState();
   return () => { use(viewState); }
}

function foobar() {
   return (viewState) => { use(viewState); }
}

Can you please let me know if there is memory leak from any of these functions?

I was told by someone that the 1st method is leaking since the viewState is passed from outside and it is being held inside the closure without being released, whereas the 2nd function is not leaking because viewState is passed as a parameter.

If that's true, I am interested in more detailed explanation.

  • Why the 1st method is leaking memory? Is it because the program is unable to remove viewState from memory automatically after it executes the code inside the arrow function?
  • Why the 2nd method where passing viewState as parameter is not causing memory leak?
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda