Jquery1.4 + Ajax IE8 Memory leakage

Source: Internet
Author: User

Upgrade jquery1.2.6 to jquery1.4. After several days of work, the Ajax polling page is not closed. The next morning, the memory is exhausted.

It is found that this memory leakage does not exist on IE6 (IE7 is not tested) and IE8 exists.

Jquery1.3.2 and jquery1.4 + do not exist.

Through comparison, we finally find a difference between the two versions.

Jquery1.4 + added a section in the Ajax MethodCodeUsed to call the onreadystatechange method in abort.

Try {
VaR oldabort = xhr. Abort;
Xhr. Abort = function (){
If (xhr ){
Oldabort. Call (xhr );
}

Onreadystatechange ();
};
} Catch (e ){}

After investigation, it is this assignment that produces an error.

The readystate of onreadystatechange is 4. When the operation succeeds, xhr. Abort is destroyed.

Memory leakage solution

In addition, if xhr. Abort = NULL, I do not know why the error is reported in IE6.

Try... Catch it. IE6 does not correct errors and does not have any problems.

The cause of this problem is unknown in IE8.

Maybe xhr. Abort and oldabort generate a closure?

But why does IE6 not leak?

Blog reference 2010.10.15

Related Article

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.