There is definitely a problem with the way jQuery (I'm using 1.3.2)
handles cleaning up namespaced events (I'm tracing the 'unload' event
codepath). The problem from what I can tell seems to be in
jQuery.event.remove:

2540         // Handle multiple events seperated by a space
2541         // jQuery(...).unbind("mouseover mouseout", fn);
2542         jQuery.each(types.split(/\s+/), function(index, type){
2543           // Namespaced event handlers
2544           var namespaces = type.split(".");
2545           type = namespaces.shift();
2546           var namespace = RegExp("(^|\\.)" +
namespaces.slice().sort().join(".*\\.") +      "(\\.|$)");

...during the 'unload' event-handler codepath, this code snippet here
is expecting the passed in 'types' argument to contain the namespaced
event-identifier (ex. 'click.foo'), but instead it is getting the
common event-identifier instead (ex. 'click').

You can firebug-trace this yourselves with the simple examples I put up here:

  http://emparq.com/ex/ex-good.html
  http://emparq.com/ex/ex-bad.html

...you'll notice the only difference between these two examples is
that one binds 'click.foo' and the other binds 'click'. In the bad
example, hitting reload constantly will see the process memory useage
go up (in essense, a leak) due to 'jQuery.event.remove' not properly
cleaning up the namespaced 'click.foo' event), while the good example
will not suffer the same results.

I'm still new-ish to jQuery and I'm not ready to hazard a solution
just yet, but I'm guessing something either needs to be done with the
way 'jQuery.event.remove' handles the value of the 'types' argument,
or this code here:

2531         for ( var type in events )
2532           this.remove( elem, type + (types || "") );

...needs to be modified to properly put those namespaced suffixes back
into the second argument. I'm not familiar enough with all of the
use-cases that this function handles, so I don't know which is the
best approach.

Can anyone else shed some light on this subject?


--Mike

On Fri, Apr 24, 2009 at 12:25 PM, Andrea Giammarchi
<andrea.giammar...@gmail.com> wrote:
> hopefully interesting:
> http://webreflection.blogspot.com/2009/04/divexpando-null-or-divremoveattributeex.html
>
> but does not solve this specific problem.
> Regards
>
> On Fri, Apr 24, 2009 at 5:29 PM, Josh Naro <joshn...@gmail.com> wrote:
>>
>> Drip seems to claim everything leaks. I've been using sIEve, and it
>> seems to give a more accurate account of the references. I also found
>> this little jQuery plugin quite useful for eliminating IE references
>> (source
>>
>> http://groups.google.com/group/jquery-en/browse_thread/thread/b66a0d05092dbeb/7ff7e0e72722db04?lnk=gst&q=remove+leak#7ff7e0e72722db04):
>>
>> jQuery.fn.discard = function(){
>>    var garbageBin = document.getElementById('IELeakGarbageBin');
>>    if (!garbageBin) {
>>        garbageBin = document.createElement('DIV');
>>        garbageBin.id = 'IELeakGarbageBin';
>>        //garbageBin.style.display = 'none';
>>        document.body.appendChild(garbageBin);
>>    }
>>
>>    this
>>        .unbind() //unbind all handlers
>>        .each(function(){ // move the element to the garbage bin
>>            garbageBin.appendChild(this);
>>            garbageBin.innerHTML = '';
>>        });
>>
>>    garbageBin = null;
>>
>> }
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to