Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

Symptoms

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.

↑ Back to the top


Cause

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

↑ Back to the top


Resolution

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.

↑ Back to the top


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): 
<!DOCTYPE>
<html>
<body>
Refresh to see leak in IE 9<br/>
<script>
function GetNestedFunction()
{
var perf = window.performance;
var timing = window.performance.timing;
var myNestedFunction =
function NestedFunction()
{
perf.timing;
}

return myNestedFunction;
}
var myPerfFunction = GetNestedFunction();

// Make this comment larger to see a larger leak
</script>
</body>
</html>
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.

↑ Back to the top


Keywords: kbtshoot, kbexpertiseadvanced, kbsurveynew, kb

↑ Back to the top

Article Info
Article ID : 2970161
Revision : 1
Created on : 1/7/2017
Published on : 6/18/2014
Exists online : False
Views : 711