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:Michael Geary (M.@Geary.com)
Date:Mar 26, 2006 1:24:24 pm
List:com.googlegroups.jquery-en

From: Dave Methvin

Also, doing some more research I think that the original Dean Edwards implementation of the event code in JQuery was written to avoid the memory leak issues:

http://dean.edwards.name/weblog/2005/10/add-event/ http://dean.edwards.name/weblog/2005/10/add-event2/

But maybe the leak may only be avoided if you removeEvents before deleting nodes.

Yeah, Dean's script doesn't leak memory in and of itself, but it doesn't do anything to protect you from the other leaks your code may cause with its own circular references or other leak patterns.

So, this code (at the top level, not inside a function) should not leak:

addEvent( document, 'load', onLoad ); function onLoad() { alert( 'loaded' ); }

But this will:

function init() { var message = 'loaded'; addEvent( document, 'load', onLoad ); function onLoad() { alert( message ); } }

init();

$.closure() breaks that closure circular reference, or removing the event handler when the page unloads will also do the trick. But there are still all the other leak patterns to worry about.

-Mike