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

275
Visualizações
How to release memory on destroying an an iframe (heap size keeps on increasing in browsers)?

I launch & destroy iframe multiple times on single page. On click of "launch" button I create iframe as mentioned in below code snippet:

$('#container').html('<iframe id="iframeUniqueId" style="height:100%; width:100%;" src=""></iframe>');
let iframe = $('#container').find('iframe');
$(iframe).attr('src', 'https://..............');

On click of "destroy" button I destroy iframe as mentioned in below code snippet:

$("#iframeUniqueId").remove();

Now, the problem here is that the heap size in browser keeps on increasing continuously when I launch & destroy the iframe multiple times. Looks like memory is not getting released on destroying the iframe. Please refer screenshot of snapshots (which I took in Windows Chrome 101):

memory leak(chrome v101)

I have checked the this issue in multiple browsers like Windows10 chrome (v101), Windows10 firefox(v100), MAC safari(v15). Please note, in safari it seems that memory is not releasing at all on destroying an iframe and memory keeps on increasing by the time(on launching/destroying iframe multiple times), looks like garbage collection is not working at all.

I am unable to find any official references/documentation(best practice) on how to handle these memory leaks in case of an iframe. Is there any workaround I can apply here which can release memory on destroying an iframe.

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