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