Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!