Referencing the "window.performance" object may cause a memory leak in Internet Explorer 9


When a reference to the window.performance object is made from the outer scope of a nested function, a permanent memory leak may occur in Windows Internet Explorer 9.


This issue occurs because the reference may cause a circular reference that Internet Explorer is unable to break when you leave the page.


Do not reference the performance object through a local variable in the outer scope of a nested function. You can also work around this issue by setting the local variable to null.

More Information

For example, the following code does not release the script memory when you leave the page (such as when you refresh the page): 
Refresh to see leak in IE 9<br/>
function GetNestedFunction()
var perf = window.performance;
var timing = window.performance.timing;
var myNestedFunction =
function NestedFunction()

return myNestedFunction;
var myPerfFunction = GetNestedFunction();

// Make this comment larger to see a larger leak
NestedFunction has a reference to the window.performance object through the enclosing scope's perf variable. NestedFunction is also referenced by the global variable, myPerfFunction, which is referenced internally by the window object because it is global.