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

158
Visualizações
Is an Image object without references marked for garbage collection as usual?

The documentation for Audio() states that its objects won't be removed from memory by the garbage collection mechanism if the playback is currently underway.

Of course the same cannot be true for Image() objects as there is no playback.
But since both represent tags, I was wondering if there are specific conditions to the garbage collection of Image objects?


Drawing an image on a canvas element might be a real world example for this:

function someFunc(url) {
  let canvas1 = document.getElementById("canvas1");
  let ctx1 = canvas1.getContext('2d');
  
  // Is this image preserved after the callback was invoked?
  let img = new Image();
  
  img.addEventListener('load', function() {
    ctx1.drawImage(img, 0, 0);
  }, {once: true});
  
  img.src = url;
}
about 4 years ago · Juan Pablo Isaza
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