The jscript parser of IE may have a memory leak.

Source: Internet
Author: User
After years at home, I feel very refreshed. Everyone may be at work tomorrow, and the next year begins. I hope you will have a new year. I have discovered a little inspiration for the New Year ~, I found that the JScript interpreter in IE may have a memory leak problem, but I never got the code that went wrong. Today I caught a reproducible case ~~

I thought that when I made the new JScript Treeview control, it was hard to be tortured. The memory usage of iexplore. EXE in the IE process is usually about MB, which leads to a slow JScript code running. Sometimes it takes several seconds to start a node @_@.

Reproduce this bug Code As follows: < Html >
< Head >
< Title > IE Memory Leak bug </ Title >
</ Head >
< Body >
< Button Onclick = "Generateobjects (this )" > Append Elements </ Button >
< Div ID = "Container" > </ Div >
< Script Language = "JavaScript" >
Function Generateobjects (elmt)
{
VaR Room = Document. getelementbyid ('Container ');
For ( VaR I = 0 ; I <   1000 ; ++ I)
{
VaROBJ= NewTestobject ('_ OBJECT __'+I );
Room. appendchild (obj. Render (document ));
}  
}

Function Testobject (name)
{
This . M_name = Name;
This . M_description = '';
This . M_element =   Null ;

This . Tostring =   Function ()
{
Return'[Class testobject]';
}
}

Function Testobject. Prototype. Render (DOC)
{
VaR Span = Doc. createelement ('span ');
* Span. Object =   This ;
* This. m_element = span;

Span. Name =   This . M_description;
Span. innertext =   This . M_name;
Span. style. Display = 'Block ';
Return Span;
}
</ Script >
</ Body >
</ Html >

Run the above Code and click "Generate Elements". The memory usage of iexpore. EXE (PM + VM) continues to rise. At this time, whether you click "refresh" or "go", the memory usage of IE will never decrease. Memory can be released unless IE is switched OFF and re-opened.

The problem lies in the two sentences "*" in the sample code above. If you comment out any sentence, after the refresh page, iexpore. the memory usage of exe will drop to the level where Ie is just opened.

If you are interested, please test this example to see if memory leak is used?

RelatedArticle:
· Continue to study the GC problem of the JScript parsing Engine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.