Microsoft KB Archive/315014

= BUG: Memory leak occurs when you remove behaviors =

Article ID: 315014

Article Last Modified on 1/17/2005

-

APPLIES TO


 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer (Programming) 6.0

-



This article was previously published under Q315014



SYMPTOMS
When you remove large behaviors, the memory usage does not decrease.



CAUSE
Scripting engines do not include a mechanism to enable Internet Explorer to force the release of certain internal objects.



RESOLUTION
To release the memory, browse to another location, or refresh the page.

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

309170 Memory leak occurs when behaviors are dynamically removed



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
  Use the following code to create a behavior named Leak.htc:    var m_div = null; function Init { m_div = document.createElement(&quot;div&quot;); m_div.innerText = &quot;This page demonstrates memory leaks with behaviors&quot;; element.appendChild(m_div);

} // Comment lines also increase the size of the behavior. Copy this 200 times to see larger leaks.    Use the following code to create a Hypertext Markup Language (HTML) file named Leak.htm to test the behavior: 

<?import namespace=&quot;leaktest&quot; implementation=&quot;Leak.htc&quot; />

function LeakMe {   var x;    for (x = 0; x < 100; x++) {     myDiv.innerHTML = &quot;&quot;; }   myDiv.innerHTML = &quot;empty div&quot;; }

<div id=&quot;myDiv&quot; style=&quot;background: yellow;&quot;>My Div <button onclick=&quot;LeakMe&quot;>Leak Me (insert htc 100x into div) </li>  Use the following code to create a simple page named Simple.htm: <a href=&quot;leak.htm&quot;>Leak Page</a> </li> Open Task Manager.</li> Double-click Simple.htm to run Internet Explorer.</li> Find the Internet Explorer process in Task Manager. Notice the memory usage.</li> Browse to Leak.htm. Notice the memory usage. Click the button several times. Every time that you click the button, a new behavior is set within the DIV tag 100 times. This removes the previous behavior, if any. Notice that the memory usage increases significantly.</li> To return the memory to a reasonable level, return to Simple.htm, or refresh the page. When you return to Simple.htm or refresh the page, the browser may stop responding for a short time period. This is because the browser must clean up the internal data structures for each inserted behavior.</li></ol>

Keywords: kbbug kbdhtml kbpending kbscript KB315014

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.