Fixing Leaks There are two common causes of memory leaks. Closures This code will cause a memory leak: function loadMyPage() { var elem = document.getElementById('myelement'); elem.onclick = function () { window.alert('hi!'); }; } To solve this, you could add: elem = null; Or, you could refactor the code somewhat: function onMyElemClick() { window.alert('hi!'); } function loadMyPage() { var elem