did anybody try to use this bad practice after removing childNodes? if(typeof CollectGarbage === "function") CollectGarbage();
moreover, something probably completely useless I use in a big WebOS like project (but if there is a chance that this does something, well, I go for it) if(typeof CollectGarbage === "function") setInterval(CollectGarbage, 60000); above horror plus JPU on top right allowed me, so far, to keep IE "under control" ( JPU: http://webreflection.blogspot.com/2007/09/jpu-javascript-cpu-monitor.html ) it is just a suggestion and in any case never trust CollectGarbage function. Regards On Wed, Apr 22, 2009 at 1:47 PM, Henry <rcornf...@raindrop.co.uk> wrote: > > On Apr 22, 9:01 am, Danny Tuppeny wrote: > > Here's a small sample page that seems to leak in the same > > way as jQuery: > > > > <html><head><script type="text/javascript"> > > function leakMe() { > > var div = document.createElement("div"); > > document.body.appendChild(div); > > document.body.removeChild(div);} > > > > </script></head><body onload="leakMe();"></body></html> > > > > The docs for Drip say that removeChild is just a psuedo-leak > > and will be cleaned up when the page is unloaded, but that > > doesn't happen. If you set the above page to Auto-refresh > > in Drip, memory usage just goes up and up forever. If you > > can find a way to stop that happening in the small sample, > > I suspect fixing jQuery will be easy. > > There is a problem here but I suspect that problem is with Drip and > not IE or JQuerry (there may be problems with IE and/or JQuery but if > so they are not being demonstrated here). > > Starting with the following more extreme example of the - appendChild > -, - removeChild - sequence; appending 100,000 DIVs, stopping with an > - alert - (to give the opportunity for garbage collection to run and > memory use to be examined), removing all of those DIVs from the DOM, > stopping again, and then repeating/looping the process, should, if the > memory leak issue exists (in relation to - removeChild - use) result > in ever increasing memory consumption, which should be noticeable > using crude examination techniques (such as reading the iexplorer > process's "Mem Usage" in Task Manage) due to the number of DIVs > created. However, using this test page:- > > <html> > <head> > <title></title> > <style type="text/css"> > </style> > </head> > <body> > <script type='text/javascript'> > function createDivs(){ > var div; > for(var c = 0;c < 100000;++c){ > div = document.createElement('DIV'); > document.body.appendChild(div); > } > alert('Divs set'); > setTimeout(clearDom, 3000); > } > > window.onload = createDivs; > > function clearDom(){ > while(document.body.lastChild){ > document.body.removeChild(document.body.lastChild); > } > alert('Divs cleared'); > setTimeout(createDivs, 3000); > } > </script> > </body> > </html> > > (The 3 second delay between function calls is to give you time to > close the browser when enough has been seen) > > - running in IE 6 (on XP) gives an oscillating (by about 9 megabytes) > "Mem Usage", with no overall accumulation of memory consumption as the > script continues to add and remove DIVs, and running in IE 8 (on XP) > showed the memory use increase with the first addition and then stay > at about that level. What I did not observe at all was any steady > increase in memory use, as would be expected if a memory leak issue > existed here. > > This suggests that IE's garbage collection is successfully dealing > with this situation without even getting to the point where re-loading > the page is significant. > > On the other hand, running the same code in Drip (with the number of > DIVs created reduced to 10,000 because Drip slows the script down > considerably) showed a steady increase in memory consumption. > Consuming more each time the DIV addition-removal cycle was executed. > > This would lead me to conclude that:- > > 1. The rumours of issues relating to the use of - removeChild - are > unsubstantiated and so should be ignored. If they do relate to a > memory leaking cause and effect relationship then the - removeChild - > use is not (in isolation, or directly) the cause of whatever effect is > being observed. > > 2. Drip should not be regarded as a definitive indicator of memory > leak issues as it appears to directly provoke some of the issues it > attempts to report. > > 3. Any supposed memory leak issues with JQuery should be demonstrated > in isolation else time and (script) performance could be squandered > attempting to 'fix' non-issues. > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---