Side navigation
#1242 closed bug (fixed)
Opened May 24, 2007 12:50PM UTC
Closed May 31, 2007 12:15AM UTC
Last modified March 15, 2012 06:00PM UTC
Unload event handlers may cause memory leaks in Internet Explorer
Reported by: | choan | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.1.3 |
Component: | event | Version: | 1.1.2 |
Keywords: | internet explorer, leaks | Cc: | |
Blocked by: | Blocking: |
Description
As the unload event handlers are not removed by the event system, they may cause memory leaks in Internet Explorer.
- This leaks seams to appears only when a jQuery page is openened in a new window which is then closed.
- The leak doesn't appear if the event handler unregisters itself.
- It'd be nice to have the fix in core (Patch attached).
Steps to reproduce:
Create a page with the following code:
$(window).unload(function(){});
Navigate to this page with Internet Explorer 6. Open some new windows, watch the memory in use grow. Close all windows except the first one. Repeat some times. (Memory usage graphic attached.)
Fixes:
If we leave the work to be done by the developer:
// Useinstead of
for unload event handlers // the handler will be autounregistered $(window).one("unload", function(){}); // Unbind the handler by itself $(window).bind("unload", function(e) { $(this).unbind(e); }); // In pre 1.1 versions $(window).bind("unload", function(e) { $(this).unbind("unload", arguments.callee); });
With the proposed fix, every one
would delegate in bind
so the programmer won't have to think about this leak.
Attachments (3)
Change History (1)
Changed May 31, 2007 12:15AM UTC by comment:1
resolution: | → fixed |
---|---|
status: | new → closed |
Thanks choan! This is a great way to help avoid those pesky memory leaks. This patch is now applied in Rev [2010].