Hmm. .remove() doesn't just hide an element; It removes it:

        if ( this.parentNode ) {
                this.parentNode.removeChild( this );
        }
(from the source)

To prevent memory leaks, it also removes event handlers associated with it. As of jQuery 1.4, it also removes data associated with it.

Maybe something else is going on? Or maybe something isn't being caught. In any case, it might help to see a test case that shows the memory leak. If you can reproduce the problem with a minimal test case and post it publicly, send a note to the jquery-dev google group so the devs can have a look.

thanks,

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Jan 12, 2010, at 6:52 PM, sophos707 wrote:

Hi everyone,
I'm running a script that processes text messages people send in, and
then it displays them on a screen.  It will loop the text messages
when there are too many to show on one screen.

To accomplish this I add DIVs with a new ID for each new message.  The
new messages push the old ones off the screen eventually.  But when
this is the case the memory in the browser just keeps increasing to a
frightening load!

I tried using $("#MyDivId").remove() to get rid of the DIVs no longer
on the screen.  Memory keeps increasing.  Found out in this forum
that .remove() just hides an element in the DOM and makes in
inaccessible rather than actually deleting it.

How can we actually delete elements?
Thanks!
- Jeff

Reply via email to