Re: [jQuery] Memory leak in blank index.htmljquery
How fast are you reloading? We have code to remove all memory leak-able code, but if it's reloading too fast, it may never get to that point. To our understanding, jQuery doesn't have any known leak points. What version of jQuery are you using? --John On 2/13/07, Michal.Till [EMAIL PROTECTED] wrote: Hi all, I was investigating a memory leak in my application and unfortunately everything led to jQuery. So I created this simple HTML file: html head script src=packages/jquery/jquery-latest.pack.js /script /head body test /body /html Then I started Drip, the IE Leak Detector (http://outofhanwell.com/ieleak/index.php?title=Main_Page) and hit the auto-refresh button. I was very surprised while viewing the memory consumption in Process Explorer (by SysInternals, now Microsoft) (the private bytes graph, that is the real allocated memory). It was climbing up and up and up... about 0.2-0.5 MB each reload. (I like the Process Explorer more than the memory graph provided by Drip). Remember, Drip is far from 100% reliable. It's function Show DOM leaks shows only some and even if it shows nothing, the app can be still leaky. Actually, it showd one element leaking, that one mentioned in http://jquery.com/dev/bugs/bug/705/ . I don't know how this bug was resolved and I think that it's not connected with the general leak in the upper code. If I add the line suggested in mentioned bug site, this record of leaking SCRIPT id=__ie_init src=//: defer __drip_hooked=true/SCRIPT goes away, but as I said, AFAIK it has nothig to do with the main problem. Thanks for answering, Michal Till ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory leak in blank index.htmljquery
Hi, How fast are you reloading? What version of jQuery are you using? To limit possible influences, I made the same experiment with plain IEs 6 and 7, reloading the test file manually, once in a 15-20 seconds interval. I use the latest file from jquery.com, 1.1.1, * Rev: 1153, Date: 2007-01-22 00:27:54 -0500. It agains shows an increase of about 100-500 kb of memory, when inspecting directly the iexplore.exe process. Can someone please verify my results? I use W XP SP2, IE 7 IE 6 (standalone IE) We have code to remove all memory leak-able code, but if it's reloading too fast, it may never get to that point. How does this work? There is some onunload code that cleans things up? Can I put my own code to window.onunload? Thanks for answering, M. Původní zpráva Od: John Resig [EMAIL PROTECTED] Předmět: Re: [jQuery] Memory leak in blank index.htmljquery Datum: 13.2.2007 16:19:27 How fast are you reloading? We have code to remove all memory leak-able code, but if it's reloading too fast, it may never get to that point. To our understanding, jQuery doesn't have any known leak points. What version of jQuery are you using? --John On 2/13/07, Michal.Till [EMAIL PROTECTED] wrote: Hi all, I was investigating a memory leak in my application and unfortunately everything led to jQuery. So I created this simple HTML file: html head script src=packages/jquery/jquery-latest.pack.js /script /head body test /body /html Then I started Drip, the IE Leak Detector (http://outofhanwell.com/ieleak/index.php?title=Main_Page) and hit the auto-refresh button. I was very surprised while viewing the memory consumption in Process Explorer (by SysInternals, now Microsoft) (the private bytes graph, that is the real allocated memory). It was climbing up and up and up... about 0.2-0.5 MB each reload. (I like the Process Explorer more than the memory graph provided by Drip). Remember, Drip is far from 100% reliable. It's function Show DOM leaks shows only some and even if it shows nothing, the app can be still leaky. Actually, it showd one element leaking, that one mentioned in http://jquery.com/dev/bugs/bug/705/ . I don't know how this bug was resolved and I think that it's not connected with the general leak in the upper code. If I add the line suggested in mentioned bug site, this record of leaking SCRIPT id=__ie_init src=//: defer __drip_hooked=true/SCRIPT goes away, but as I said, AFAIK it has nothig to do with the main problem. Thanks for answering, Michal Till ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory leak
Thanks for your reply. I downloaded the latest from SVN and built it, but I still have the same memory leak. Anyhow I still can't figure out where the memory leak is, I'm not sure if it's my code or jQuery. Brandon Aaron wrote: Please grab the latest from SVN as it fixes the memory leak in IE. -- Brandon Aaron On 12/11/06, Ethan Hannagan [EMAIL PROTECTED] wrote: Hi, Can you help me spot what is causing the memory leak in the following code? If I click reload, bind, and clean several times, the memory allocation for IE stays still. But if I click in the reload bind and then clean, several times, the memory allocation keeps climbing. I appreciate any feedback you may have. Thanks, Ethan = html head script type=text/javascript src=jquery-1.0.3.js/script meta http-equiv=content-type content=text/html / titleIE Memory Leak/title /head body button id=reloadreload/buttonbr button id=bindbind/buttonbrbr button id=reloadnbindreload bind/buttonbrbr button id=cleanclean!/buttonbr div id=container style=border:1px solid red/div div id=counter style=border:1px solid green/div script type=text/javascript var counter = 1; function reload(callback){ $(#container).load(template.html, callback); } function bind(){ var p = $(this).find(p); p.click(function(){}); p.get(0).bigString = new Array(1000).join(new Array(1000).join(X)); $(#counter).html(counter++); } $(#reload).click(reload); $(#bind).click(bind); $(#reloadnbind).click(function(){ reload(bind); }); $(#clean).click(function(){ var p = $(#container).find(p); p.unbind(); p.get(0).onclick = null; $(#container).html(); }); /script /body /html -- View this message in context: http://www.nabble.com/Memory-leak-tf2792655.html#a7791251 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/Memory-leak-tf2792655.html#a7836682 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory leak
Ethan Hannagan schrieb: Thanks for your reply. I downloaded the latest from SVN and built it, but I still have the same memory leak. Anyhow I still can't figure out where the memory leak is, I'm not sure if it's my code or jQuery. I think it's because you have a circular reference here, created by the closure: function bind() { var p = $(this).find(p); p.click(function(){}); } -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory leak
The purpose of the bigString expando is just to create a huge object and make it easier to spot that there's a memory leak. Citrus wrote: I think that the reloadandbind call may be creating a closure that you're not intending. But, that's just me looking at the code for 5 minutes, I might not be seeing it straight. Also, it's a bad idea to stick custom js objects onto DOM objects - specifically bigString. It causes conflicts between IE's two garbage collectors. You should create a js object instead that has a DOM element as a member, and also the custom (bigString) part as a member. foo = { para: p.get(0), bigString: ... } Lastly, while I don't know what effect this has, I'd say that you shouldn't be calling new Array() if you don't have to. I hope that some of this helps. - Brian Thanks for your reply. I downloaded the latest from SVN and built it, but I still have the same memory leak. Anyhow I still can't figure out where the memory leak is, I'm not sure if it's my code or jQuery. Brandon Aaron wrote: Please grab the latest from SVN as it fixes the memory leak in IE. -- Brandon Aaron On 12/11/06, Ethan Hannagan [EMAIL PROTECTED] wrote: Hi, Can you help me spot what is causing the memory leak in the following code? If I click reload, bind, and clean several times, the memory allocation for IE stays still. But if I click in the reload bind and then clean, several times, the memory allocation keeps climbing. I appreciate any feedback you may have. Thanks, Ethan = html head script type=text/javascript src=jquery-1.0.3.js/script meta http-equiv=content-type content=text/html / titleIE Memory Leak/title /head body button id=reloadreload/buttonbr button id=bindbind/buttonbrbr button id=reloadnbindreload bind/buttonbrbr button id=cleanclean!/buttonbr div id=container style=border:1px solid red/div div id=counter style=border:1px solid green/div script type=text/javascript var counter = 1; function reload(callback){ $(#container).load(template.html, callback); } function bind(){ var p = $(this).find(p); p.click(function(){}); p.get(0).bigString = new Array(1000).join(new Array(1000).join(X)); $(#counter).html(counter++); } $(#reload).click(reload); $(#bind).click(bind); $(#reloadnbind).click(function(){ reload(bind); }); $(#clean).click(function(){ var p = $(#container).find(p); p.unbind(); p.get(0).onclick = null; $(#container).html(); }); /script /body /html -- View this message in context: http://www.nabble.com/Memory-leak-tf2792655.html#a7791251 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/Memory-leak-tf2792655.html#a7836682 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/Memory-leak-tf2792655.html#a7837984 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory leak
Yes, but when I click on the 'clean' button, Im unbinding and clearing out the event, to avoid memory leak, but somehow the leak is still there. When I click in the clean button, this code gets executed... var p = $(#container).find(p); p.unbind(); p.get(0).onclick = null; $(#container).html(); But I don't know what else I need to clear out to get rid of the memory leak. Klaus Hartl wrote: Ethan Hannagan schrieb: Thanks for your reply. I downloaded the latest from SVN and built it, but I still have the same memory leak. Anyhow I still can't figure out where the memory leak is, I'm not sure if it's my code or jQuery. I think it's because you have a circular reference here, created by the closure: function bind() { var p = $(this).find(p); p.click(function(){}); } -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/Memory-leak-tf2792655.html#a7838041 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory Leak
Which version/revision of jQuery are you using? -- Brandon Aaron On 12/7/06, Jeff Ober [EMAIL PROTECTED] wrote: I'm getting a memory leak in this function, which iterates over a series of items in the object allSections, showing a question set in the object and a yes/no answer, which then get inserted in an array of results. In Drip (memory leak finder for IE), I'm seeing the anchors (with the class 'answer') as leaking. I've tried unbinding them at the beginning of the function, before they are destroyed (with just a $('.answer').unbind('click')), but they still show up as lost dom objects and they show as having an empty function object as their onclick property. I can't think what I'm missing... function showQuestion(qIndex) { $('.answer').unbind('click'); if (typeof allSections[qIndex] != 'undefined') { var category = allSections[qIndex]; if (category.title == 'Basics') { indicesChosen.push(qIndex); qIndex++; showQuestion(qIndex); } else { $('#index').empty().html('Question '+(qIndex)+' of '+(allSections.length-1)); $('#question').empty().html(category.question+' '); $('#question').append($('Yes / No')); $('.answer').click(function() { if ($(this).html() == 'Yes') { indicesChosen.push(qIndex); } qIndex++; showQuestion(qIndex); }); } } else completeWizard(); } Have a burning question? Go to Yahoo! Answers and get answers from real people who know. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory Leak
Version 1.0.3. Also, yahoo rewrote my syntax there a bit - those yes/no links should actually be written out: $('#question').append($('a id=yes href=# class=answerYes/a / a id=no href=# class=answerNo/a')); ...hopefully that won't get rewritten :) Jeff --- Brandon Aaron [EMAIL PROTECTED] wrote: Which version/revision of jQuery are you using? -- Brandon Aaron On 12/7/06, Jeff Ober [EMAIL PROTECTED] wrote: I'm getting a memory leak in this function, which iterates over a series of items in the object allSections, showing a question set in the object and a yes/no answer, which then get inserted in an array of results. In Drip (memory leak finder for IE), I'm seeing the anchors (with the class 'answer') as leaking. I've tried unbinding them at the beginning of the function, before they are destroyed (with just a $('.answer').unbind('click')), but they still show up as lost dom objects and they show as having an empty function object as their onclick property. I can't think what I'm missing... function showQuestion(qIndex) { $('.answer').unbind('click'); if (typeof allSections[qIndex] != 'undefined') { var category = allSections[qIndex]; if (category.title == 'Basics') { indicesChosen.push(qIndex); qIndex++; showQuestion(qIndex); } else { $('#index').empty().html('Question '+(qIndex)+' of '+(allSections.length-1)); $('#question').empty().html(category.question+' '); $('#question').append($('Yes / No')); $('.answer').click(function() { if ($(this).html() == 'Yes') { indicesChosen.push(qIndex); } qIndex++; showQuestion(qIndex); }); } } else completeWizard(); } Have a burning question? Go to Yahoo! Answers and get answers from real people who know. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory Leak
Daggone it. One more try: $('#question').append($('lt;a id=yes href=# class=answergt;Yeslt;/agt; / lt;a id=no href=# class=answergt;Nolt;/agt;')); --- Jeff Ober [EMAIL PROTECTED] wrote: Version 1.0.3. Also, yahoo rewrote my syntax there a bit - those yes/no links should actually be written out: $('#question').append($('a id=yes href=# class=answerYes/a / a id=no href=# class=answerNo/a')); ...hopefully that won't get rewritten :) Jeff --- Brandon Aaron [EMAIL PROTECTED] wrote: Which version/revision of jQuery are you using? -- Brandon Aaron On 12/7/06, Jeff Ober [EMAIL PROTECTED] wrote: I'm getting a memory leak in this function, which iterates over a series of items in the object allSections, showing a question set in the object and a yes/no answer, which then get inserted in an array of results. In Drip (memory leak finder for IE), I'm seeing the anchors (with the class 'answer') as leaking. I've tried unbinding them at the beginning of the function, before they are destroyed (with just a $('.answer').unbind('click')), but they still show up as lost dom objects and they show as having an empty function object as their onclick property. I can't think what I'm missing... function showQuestion(qIndex) { $('.answer').unbind('click'); if (typeof allSections[qIndex] != 'undefined') { var category = allSections[qIndex]; if (category.title == 'Basics') { indicesChosen.push(qIndex); qIndex++; showQuestion(qIndex); } else { $('#index').empty().html('Question '+(qIndex)+' of '+(allSections.length-1)); $('#question').empty().html(category.question+' '); $('#question').append($('Yes / No')); $('.answer').click(function() { if ($(this).html() == 'Yes') { indicesChosen.push(qIndex); } qIndex++; showQuestion(qIndex); }); } } else completeWizard(); } Have a burning question? Go to Yahoo! Answers and get answers from real people who know. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory Leak
Jeff Ober schrieb: Version 1.0.3. Also, yahoo rewrote my syntax there a bit - those yes/no links should actually be written out: $('#question').append($('a id=yes href=# class=answerYes/a / a id=no href=# class=answerNo/a')); ...hopefully that won't get rewritten :) There's a redundant jQuery object...: $('#question').append('a id=yes href=# class=answerYes/a / a id=no href=# class=answerNo/a'); :-) -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory Leak
On 12/7/06, Jeff Ober [EMAIL PROTECTED] wrote: Version 1.0.3. Also, yahoo rewrote my syntax there a bit - those yes/no links should actually be written out: I'm having trouble remembering now but I believe a memory leak was introduced in 1.0.3 and the latest in SVN should resolve this. Can you try the latest from SVN? -- Brandon Aaron ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory Leak
Thanks for pointing that out. It doesn't seem to make a difference, though, when I take it out. The dom objects are still getting left behind. --- Klaus Hartl [EMAIL PROTECTED] wrote: Jeff Ober schrieb: Version 1.0.3. Also, yahoo rewrote my syntax there a bit - those yes/no links should actually be written out: $('#question').append($('a id=yes href=# class=answerYes/a / a id=no href=# class=answerNo/a')); ...hopefully that won't get rewritten :) There's a redundant jQuery object...: $('#question').append('a id=yes href=# class=answerYes/a / a id=no href=# class=answerNo/a'); :-) -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ Yahoo! Music Unlimited Access over 1 million songs. http://music.yahoo.com/unlimited ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Memory Leak
That appears to take care of it. Thanks for the pointer! --- Brandon Aaron [EMAIL PROTECTED] wrote: On 12/7/06, Jeff Ober [EMAIL PROTECTED] wrote: Version 1.0.3. Also, yahoo rewrote my syntax there a bit - those yes/no links should actually be written out: I'm having trouble remembering now but I believe a memory leak was introduced in 1.0.3 and the latest in SVN should resolve this. Can you try the latest from SVN? -- Brandon Aaron ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/