Looks like Firefox already has it:

Googling "DOMNodeRemovedFromDocument site:microsoft.com" brings no
joy, however. :-)
T.J. Crowder
tj / crowder software / com

On Oct 30, 9:02 am, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
> Hi,
> FWIW, I don't think this is a bug in Prototype.  Prototype keeps track
> of the event handlers it hooks up so it can unhook them on page unload
> to work around memory leaks in IE.  (This also lets it provide the new
> stopObserving functionality in release 1.6 where you don't have to
> specify the handler to unhook things.)  This means that it has to use
> a small bit of memory to track the handlers.  That's not a *leak*, I
> wouldn't say, but a *use* of memory.
> If you remove an element from the DOM (directly or by removing its
> ancestor), I think it's incumbent on your application logic to remove
> any handlers you've registered for it as well.  Your function that
> does this with a select("*") is obviously one way to do that, but
> ideally there'd be something more finely-grained that app logic could
> handle.  Personally, I wouldn't want to see the select("*") thing
> added to Prototype (for instance, in the Element.update method),
> because I don't want that overhead every time I remove an element if I
> know I don't have any handlers registered on it.
> Someday we may get access to the DOM event
> DOMNodeRemovedFromDocument[1].  Now that would be nice, because it
> would give us notification of an element being removed and let us
> release any memory we have associated with it.  (I'm not sure I'd want
> Prototype to do it for me even then, but I'll make that call when/if
> we get the event.)
> [1]http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/
> If it's very complicated in your app to know which elements within the
> element being replaced are being watched, you might look at event
> delegation instead, which involves fewer handlers placed at a higher
> (e.g., container) level.
> --
> T.J. Crowder
> tj / crowder software / com
> On Oct 30, 7:57 am, "Yee Keat Phuah" <[EMAIL PROTECTED]> wrote:
> > Hi,
> > Was trying to cut the memory leak reported with this tool 
> > ->http://home.wanadoo.nl/jsrosman/.
> > Found out that there are some memory leaks in prototype's
> > Event.observe, only when the element that is observed is not within
> > the document DOM, this might happen when
> > 1. I have not attached the element into the DOM, or that
> > 2. I have removeChild or replaceChild the element that was observed
> > on. (this is what I encountered in my project)
> > I see this as a leak in prototype because using the attachEvent
> > (button 2 in the test page) equivalent does not present the same leak.
> > Attaching the element into the document (button 3 in the test page)
> > also does not present the same leak.
> > I have found that the fix from this thread 
> > ->http://groups.google.com/group/prototype-core/browse_thread/thread/c2...
> > solves the problem, contrary to the original poster who reported it
> > only for IE6, my test program shows that the leak happens for IE7 as
> > well.
> > For my project, instead of using the straight forward:
> > parent.replaceChild(newnode, oldnode);
> > I have to do this instead:
> > $(oldnode).select("*").each(function(e) {
> >   $(e).stopObserving();});
> > parent.replaceChild(newnode, oldnode);
> > That's quite a lot of work.
> > Hope to see this fixed in 1.6.1 if not 1.6.0.
> > Cheers,
> > Phuah  Yee Keat
> >  testobserve.html
> > 2KViewDownload
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to