Internet Explorer 11 SPA iframe memory leak
<p>In my company we are working on a SPA with multiple iframes. Occasionally some of the frames would not load on IE 11 because IE ran out of memory (the iframe content could be quite heavy on the RAM but things are okay on Chrome and FF). </p>

<p>In fact we monitored the fact that each time we reload the page, the memory used (data taken from either IE memory analyzer or the windows task manager) kept increasing until it reaches a 1.6Gb threshold.</p>

<p>I've found this <a href="https://stackoverflow.com/questions/8407946/is-it-possible-to-use-iframes-in-ie-without-memory-leaks">very interesting post</a> and I thought that all my troubles would fly away. As we are not using jQuery I adapted this provided snippet to vanilla JS.
My idea was to clear the frames before the page reload to check if the memory used would be reclaimed.</p>

<p>Here is the code I wrote : </p>

<pre><code>window.addEventListener('beforeunload', function () {
    [].slice.call(document.querySelectorAll('iframe')).forEach(function (frame) {
        // remove all frame children
        while (frame.contentWindow.document.body.firstChild) {
            frame.contentWindow.document.body.removeChild(frame.contentWindow.document.body.firstChild);
        }      
        frame.src = 'about:blank';
        frame.parentNode.removeChild(frame);
    });
    // force garbarge collection for IE only
    window.CollectGarbage &amp;&amp; window.CollectGarbage();
});
</code></pre>

<p>I then opened the memory profiler of IE and reloaded the application. However very little of the memory was reclaimed and I ended up with something like this <a href="https://i.stack.imgur.com/bjn1S.png" rel="nofollow noreferrer">memory diagram</a></p>

<p>Am I missing something. Has some any information or piece of advice ?</p>

<p>Thank you.</p>