No need for that. I don't know why is that necessary but the previous
call to remove() should handle this.
I suppose that handles comment/text nodes and stuff like that. They
won't leak any memory.

On Wed, Nov 26, 2008 at 12:28 PM, Chris Robinson <[EMAIL PROTECTED]> wrote:
> The error comes up if you try to do this in the empty() call:
>
>  this.firstChild.outerHTML = '';
>
> I changed my code base to use 'outerHTML' for the remove() function and use
> the other 'garbage bin' method for the firstChild issue.  I am running tests
> now and will get back to everyone shortly.
>
> -Chris
>
> On Wed, Nov 26, 2008 at 8:21 AM, Ariel Flesler <[EMAIL PROTECTED]> wrote:
>>
>> Which nodes generate an error ?
>>
>> On Wed, Nov 26, 2008 at 5:53 AM, Andrea Giammarchi
>> <[EMAIL PROTECTED]> wrote:
>> > Hi Ariel, is this what you would apply for each nested node in case of
>> > $.empty() ?
>> >
>> > The only problem I can see is with nodes that generate an error if
>> > outerHTML
>> > property is assigned and a try catch could decrease execution speed.
>> >
>> > Any ideas?
>> >
>> > Regards
>> >
>> > On Tue, Nov 25, 2008 at 11:30 PM, Ariel Flesler <[EMAIL PROTECTED]>
>> > wrote:
>> >>
>> >> Well... I concluded a nicer solution and asked you to try it.
>> >> But you never replied...
>> >>
>> >> http://dev.jquery.com/ticket/3553
>> >>
>> >> if (this.parentNode)
>> >>        this.parentNode.removeChild( this );
>> >> if (jQuery.browser.msie)
>> >>        this.outerHTML = "";
>> >>
>> >> --
>> >> Ariel Flesler
>> >> http://flesler.blogspot.com/
>> >>
>> >> On Nov 25, 3:28 pm, "Chris Robinson" <[EMAIL PROTECTED]> wrote:
>> >> > Hey Nick,
>> >> >
>> >> > this was never completely resolved.  The edited jQuery source I was
>> >> > playing
>> >> > around with is
>> >> >
>> >> > here:http://www.outsidethediv.com/memory-leak-test/js/jquery-1.2.6-updated.js
>> >> >
>> >> > You can try swapping your jquery include with it and see if that
>> >> > helps
>> >> > at
>> >> > all.  It seemed to help out a good deal in my case but was rather
>> >> > inconclusive in smaller stripped down tests.
>> >> >
>> >> > On Tue, Nov 25, 2008 at 9:30 AM, Nick <[EMAIL PROTECTED]> wrote:
>> >> >
>> >> > > I am having a very similar problem.  Can someone give more details
>> >> > > as
>> >> > > how to modify the JQ source file to fix this?
>> >> >
>> >> > > I have noticed (in Drip) that when I refresh the page, the DOM
>> >> > > nodes
>> >> > > duplicate.  This doesn't make any sense to me since I know JQ
>> >> > > unbinds
>> >> > > everything on page unload in IE.  This node duplication is leading
>> >> > > to
>> >> > > some serious memory issues in my app that needs to run for up to 8
>> >> > > hours straight without a browser restart.
>> >> >
>> >> > > Any help would be much appreciated.
>> >> >
>> >> > > Thanks,
>> >> > > Nick
>> >> >
>> >> > > On Oct 24, 12:50 pm, chris robinson <[EMAIL PROTECTED]> wrote:
>> >> > > > Hey all,
>> >> >
>> >> > > > I believe I have found a leak and have the beginnings of a
>> >> > > > solution
>> >> > > > to
>> >> > > > it.
>> >> >
>> >> > > > I'm writing an app that preforms ajax searching that returns
>> >> > > > pretty
>> >> > > > large result sets.  I render them via jQuery into a tbody.  once
>> >> > > > a
>> >> > > > subsequent search is performed I call tbody.empty() and append
>> >> > > > the
>> >> > > > new
>> >> > > > results.  I created a test harness that would perform a
>> >> > > > predefined
>> >> > > > search 5000 times in a row with a good amount of time in between.
>> >> >
>> >> > > > I noticed that IE was allocating quite a bit of memory and never
>> >> > > > reclaiming it.  At first I thought it was a closure or circular
>> >> > > > reference on my part.  Once I was sure I had removed them I ran
>> >> > > > more
>> >> > > > test, sure enough it was still allocating a lot of memory.
>> >> > > >  Through
>> >> > > > a
>> >> > > > lot of research I found this articlehttp://
>> >> > >www.scribd.com/doc/2159768/Ajax-Part2
>> >> > > > which says that JS's removeChild will leak in IE.  Microsoft uses
>> >> > > > another method to remove which is essentially this:
>> >> >
>> >> > > > function DestroyElement(elem) {
>> >> > > >       var garbageBin =
>> >> > > > document.getElementById('IEMemoryLeakGarbageBin');
>> >> > > >       if(garbageBin === undefined) {
>> >> > > >              garbageBin = document.createElement("DIV");
>> >> > > >              garbageBin.id = "IEMemoryLeakGarbageBin";
>> >> > > >              garbageBin.style.display = 'none';
>> >> > > >              document.body.appendChild(garbageBin);
>> >> > > >       }
>> >> > > >       garbageBin.appendChild(elem);
>> >> > > >       garbageBin.innerHTML = "";
>> >> >
>> >> > > > }
>> >> >
>> >> > > > I went through jQuery 1.2.6 and replaced the removeChild
>> >> > > > references
>> >> > > > with a check for IE, and if so use this, else use the regular
>> >> > > > removeChild.  After doing so and rerunning my test I saw drastic
>> >> > > > improvements in memory being reallocated after my elements were
>> >> > > > removed from the document.
>> >> >
>> >> > > > I also ran these test on FF, with or without this change it ran
>> >> > > > the
>> >> > > > same way, recollecting memory correctly.
>> >> >
>> >> > > > this is only seems to be a drastic performance increase if you
>> >> > > > are
>> >> > > > creating 1000+ dom elements and binding events to them, but, the
>> >> > > > app
>> >> > > > I
>> >> > > > am writing has to be able to run all day with out leaving or
>> >> > > > refreshing the page.
>> >> >
>> >> > > > I just thought the Dev team might be interested in my findings.
>> >> > > >  I
>> >> > > > plan on striping this down and writing conclusive tests and
>> >> > > > documentation over the weekend.
>> >> >
>> >> > > > -Chris
>> >> >
>> >> >
>> >>
>> >
>> >
>> > >
>> >
>>
>>
>>
>> --
>> Ariel Flesler
>> http://flesler.blogspot.com
>>
>>
>
>
> >
>



-- 
Ariel Flesler
http://flesler.blogspot.com

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to