 <p>If you are using Chrome, you should use the "Timeline" to record the memory usage. Launch the timeline, then wait for the page to refresh a few times, and then stop the timeline and have a look at the results. If you see the line keeping increasing, that means your objects in memory (or the DOM nodes) are never released and garbage collected.</p> <p>I have never used <code>document.open/write</code> myself so I do not know if that can cause issues with garbage collection, but I suspect it does.</p> <p>If your detect clearly a memory lak using the Timeline, then open the "Profiles" tab and take a Heat snapshot before and after a page reload, then use "comparison" to see what have changed and how much bigger your memory impact is. If for instance your old compiled code (or obejct references) is still there, plus the new one, then it explains your leak.</p>