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

184
Visualizações
Imported scripts not cleaned up from memory when Angular application is destroyed

I have an Angular application, and have noticed that when the page is closed (and application is destroyed) some script imports linger in memory. This is for instance what the Chrome's memory profiler tells me after I opened and closed my application twice since the last memory snapshot:

memory snapshot

As you can see, there are a couple of vendor.js elements in (compiled code) that are not accessible to the GC (distance is -).

Something that I found is that, if I manually remove the vendor.js script tag (i.e. I open the Elements tab in the dev tools, then hit Del to remove the script tag), then close the app, there is no memory leak anymore.
However, if I try to remove the script tag from the console (using for instance document.body.getElementsByTagName('script')[1].remove() which targets the correct script), I get a memory snapshot diff looking like the following:

enter image description here

enter image description here

So I guess my questions are:

  1. What is happening here? Why are the scripts not properly cleaned up when closing the window?
  2. Why is there a difference between manually removing the DOM script node in the dev tools vs doing it via javascript?
  3. Is there a solution?

I didn't find much on the web. I came across these:

  • https://github.com/angular/angular/issues/17637#issuecomment-387801113, but the solution proposed didn't do anything
  • as well as the things suggested there: https://github.com/angular/angular/issues/17637#issuecomment-351094525
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