atom feed22 messages in com.googlegroups.jquery-en[jQuery] Memory leaks forever
FromSent OnAttachments
Franck MarciaMar 25, 2006 7:13 am 
Dave MethvinMar 25, 2006 8:55 am 
Franck MarciaMar 25, 2006 9:08 am 
John ResigMar 25, 2006 9:15 am 
Dave MethvinMar 25, 2006 10:07 am 
Michael GearyMar 25, 2006 10:07 am 
Franck MarciaMar 25, 2006 10:39 am 
Michael GearyMar 25, 2006 10:56 am 
Dave MethvinMar 25, 2006 11:05 am 
Franck MarciaMar 25, 2006 1:45 pm 
Michael GearyMar 25, 2006 2:19 pm 
Franck MarciaMar 25, 2006 5:16 pm 
Dave MethvinMar 26, 2006 9:02 am 
Michael GearyMar 26, 2006 1:24 pm 
Franck MarciaMar 28, 2006 2:25 am 
Dave MethvinMar 28, 2006 5:45 am 
John ResigMar 28, 2006 7:30 am 
Franck MarciaMar 28, 2006 8:26 am 
jqu...@vikas.mailshell.comMar 28, 2006 8:57 am 
John ResigMar 28, 2006 9:03 am 
Michael GearyMar 28, 2006 9:14 am 
jqu...@vikas.mailshell.comMar 28, 2006 9:24 am 
Subject:[jQuery] Memory leaks forever
From:John Resig (jere@gmail.com)
Date:Mar 28, 2006 7:30:03 am
List:com.googlegroups.jquery-en

Sorry, I'm just mesmerized by this code: [0,1,1,1,0][xml.readyState] that's seriously one of the coolest boolean ideas that I've seen.

(btw, I like your timeout and memory leak catches, I'll try and push them into svn asap)

--John

On 3/28/06, Franck Marcia <franck.marcia at gmail.com> wrote:

I found it !!! :-D

Nothing about DOM insertion order, events, circular references or whatever...

In $.xml, you must "nullify" xml object at the end of onreadystatechange.

btw, here is my implementation of timeouts management:

$.xml = function(type, url, data, ret, to) {

var xml = new XMLHttpRequest(); var t; to = to || false;

if (xml) { xml.open(type || "GET", url, true);

if (data) xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

if (ret) xml.onreadystatechange = function() { if (xml.readyState == 4) { ret(xml); xml.onreadystatechange = function(){}; xml = null; // <-- here if (to) window.clearTimeout(t); } };

if (to) { t = window.setTimeout(function(){ if ([0,1,1,1,0][xml.readyState]) { xml.abort(); ret(xml); xml.onreadystatechange = function(){}; xml = null; }}, to); } xml.send(data);

} };

$.get = function(url, ret, type, to) { $.xml("GET", url, null, function(r) { if (ret) ret($.httpData(r, type)); }, to); };

$.post = function(url, data, ret, type, to) { $.xml("POST", url, $.param(data), function(r) { if (ret) ret($.httpData(r, type)); }, to); };

Franck, happy guy.