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

188
Vistas
why did console.log seem to cause memory leaks in Chrome?

I have a function a where there is a function b that references foo in its closure.

class Foo {}

function a() {
  const foo = new Foo()
   const b = () => {
        foo // referencing `foo`
    }
    b()
};

a() // no memory leaks

after I executed a, there are no memory leaks for Foo.

I also tweaked it slightly. Still, no memory leaks for the following examples.

class Foo {}

function a() {
  const foo = new Foo()
   const b = () => {
        if(foo === 'foo') {
            
        }
    }
    b()
};
a() // no memory leaks

class Foo {}

function a() {
  const foo = new Foo()
   const b = () => {
        console.log(foo.lol)
    }
    b()
};
a() // no memory leaks

But as soon as I logged out foo, it causes memory leaks.

class Foo {}

function a() {
  const foo = new Foo()
   const b = () => {
        console.log(foo)
    }
    b()
};
a() // memory leaks

enter image description here

My question is why console.log(fii) leaks but referencing foo in other ways or log out its property console.log(foo.lol)

I tested these in Chrome 103 DevTool console.

about 4 years ago · Santiago Gelvez
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