Opened 10 years ago
Closed 10 years ago
#7762 closed enhancement (fixed)
[Events] Remove CPU overhead on unload
| Reported by: | iliakan | Owned by: | iliakan |
|---|---|---|---|
| Priority: | low | Milestone: | 1.5 |
| Component: | event | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
There is a bug in IE6 which causes inter-page memory leaks. It is fixed in latest IE6 and IE7, in which the lesser, intra-page memory leak still exists.
The code in events.js fixes this bug by clobbering event handlers:
if ( window.attachEvent && !window.addEventListener) {
jQuery(window).bind("unload", function() {
alert(1)
for ( var id in jQuery.cache ) {
if ( jQuery.cache[ id ].handle ) {
// Try/Catch is to handle iframes being unloaded, see #4280
try {
jQuery.event.remove( jQuery.cache[ id ].handle.elem );
} catch(e) {}
}
}
});
}
But actually it is required in IE6 only and causes extra CPU load in IE7, IE8.
Change History (7)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
| Owner: | set to iliakan |
|---|---|
| Status: | new → pending |
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!
Additionally, test against the latest jQuery release and the jQuery 0 GIT version to ensure the issue still exists. Be Excellent to eachother!
Additionally - patches should be submitted in the form of committed pull requests to the github repo, https://github.com/jquery/jquery
comment:4 Changed 10 years ago by
Conditional comments can be replaced by
if ( && !window.XmlHttpRequest )
The point is to prevent IE6 code from adding overhead on IE7 and IE8.
comment:5 Changed 10 years ago by
New pull, after discussion with rwaldron and jaubourg: https://github.com/jquery/jquery/pull/136
comment:6 Changed 10 years ago by
| Component: | unfiled → event |
|---|---|
| Milestone: | 1.next → 1.5 |
| Priority: | undecided → low |
| Status: | new → open |
Superceded by https://github.com/jquery/jquery/pull/149
comment:7 Changed 10 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | open → closed |
Merge branch 'fix7762' into jquery master. Fixes #7762.
Changeset: 429b078dc7b5cf7765b44c8d32e125ecd8f1e2c9

The patch:
diff --git a/src/event.js b/src/event.js index fd470e7..2b9696e 100644 --- a/src/event.js +++ b/src/event.js @@ -1181,7 +1181,7 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl // Window isn't included so as not to unbind existing unload events // More info: // - http://isaacschlueter.com/2006/10/msie-memory-leaks/ -if ( window.attachEvent && !window.addEventListener ) { +if ( window.attachEvent && !window.addEventListener /*@cc_on @if (@_jscript_version > 5.6) && 0 /*@end @*/) { jQuery(window).bind("unload", function() { for ( var id in jQuery.cache ) { if ( jQuery.cache[ id ].handle ) {