Removing iframe content from onunload / onbeforeunload memory in IE7

I have an iframe that loads on my page via ajax. At each interval, the new iframe overwrites the old. For some reason, the contents of the iframe remain in my memory in IE7. I am sure that this is the contents of the iframe, because when I load a small site in an iframe, the size of the memory increases slowly. When I load a large site into the frame, it speeds up with each update.

I would like to clear the contents of the iframe from memory every time an interval is called. I tried the scripts below (this one for windows.onunload - I also tried this every interval), but both of them do not work and keep the iframe contents in my memory until I end the browser session.

// Remove iframecontents window.onunload = function() { $('iframe').each(function(i, frame) { frameDoc = frame.contentDocument || frame.contentWindow.document; frameDoc.removeChild(frameDoc.documentElement); }); } // Remove iframe with jQuery window.onunload = function() { $('iframe').each(function(i, frame) { $(frame).remove(); }); } 

If there is a way to remove content from an iframe from my memory without restarting the browser?

These solutions do not seem to work either: iframe control and memory in javascript jQuery DOMWindow script does not free memory

+4
source share
1 answer

My experience with IE with Windows 7 has always been that you cannot explicitly force it to collect garbage. It works along with Windows Dynamic Memory Management. If your system as a whole is not enough for memory, then IE will start releasing memory more often. If you have a lot of memory available, it will continue until you kill the process.

However, the truth is, each page (or iframe) draws in a certain amount of memory, and IE tends to unload a large chunk from it only when you move. This is a bad situation for SPA applications (single page applications). This makes correct coding even more important in order to preserve memory consumption in the first place.

+1
source

Source: https://habr.com/ru/post/1492982/


All Articles