Side navigation
#2123 closed bug (fixed)
Opened January 08, 2008 01:04PM UTC
Closed February 17, 2008 06:54AM UTC
IE6 memory leak with custom / pseudo events
Reported by: | the_undefined | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.2.2 |
Component: | event | Version: | 1.2.1 |
Keywords: | Cc: | haimuiba@gmail.com | |
Blocked by: | Blocking: |
Description
Hi folks,
first of all thanks for all the good things that went into 1.2.2b so far, it fixes some real nasty memory leaks present in 1.2.1 related to events.
However, there still seems to be something weird going on with custom (i.e. non standard) events. Consider the following example:
$(function() { $('h1:first').bind('pseudoEvent', function() {}); });
If you keep refreshing a page with an h1 element and this code, you'll see memory going through the roof in IE6. (I highly recommend Drip's auto-refresh function for testing this).
Now even more disturbing is the fact that if I directly unbind the event like this:
$(function() { $('h1:first').bind('pseudoEvent', function() {}); $('h1:first').unbind('pseudoEvent'); });
The memory leak still occurs.
If using custom events like this is not considered to be a good practice please let me know so I can refactor my code ; ).
Thanks, Felix
Attachments (0)
Change History (4)
Changed January 08, 2008 04:24PM UTC by comment:1
resolution: | → fixed |
---|---|
status: | new → closed |
Changed January 08, 2008 04:26PM UTC by comment:2
Also if you are interested, the memory leak is discussed in the comments of this ticket
Changed January 10, 2008 02:24PM UTC by comment:3
resolution: | fixed |
---|---|
status: | closed → reopened |
This should be fixed already in 1.2.2b2.
My bad, I was actually testing this in 1.2.2b2 (r4269) not '1.2.2b'. So if you get a chance try to see if you can replicate this issue with the code given above.
For your convenience you can use this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr" id="html" lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Memory Leak</title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(function() { $('h1:first').bind('pseudoEvent', function() {}); $('h1:first').unbind('pseudoEvent'); }); </script> </head> <body id="body"> <h1>Test element</h1> </body></html>
Btw. is there any reason trac wouldn't email me about changes on this ticket? Maybe SMTP not setup or sth?
Changed February 17, 2008 06:54AM UTC by comment:4
resolution: | → fixed |
---|---|
status: | reopened → closed |
This was fixed in 1.2.2 final. Email updates aren't enabled.
This should be fixed already in 1.2.2b2.
http://groups.google.com/group/jquery-dev/browse_thread/thread/498e1bdaa4017b1b/63c0b10a1a5b5281
If you could re-run your tests with b2 and reopen the bug if you still have a problem we'd appreciate it. Memory leaks are always tricky.
In case you were wondering what the problem was, it appears IE6 is fine with attaching a pseudo event to an element, but fails when it tries to detach it. This leaves the event handler on the element and causes the memory leak since the garbage collection can't handle it correctly.