We've talked about doing this before, but there are a couple problems. First, we can't do what you're suggesting for Element#remove — the function returns the removed element, which may then be appended somewhere else in the document. If the element is going to be discarded, then one ought to remove its listeners; but if it will be reused, the user would expect those listeners to remain. I'm not sure how to get around this.
We have also talked about removing event listeners on an Element#update call, but are hesitant to do so automatically for performance reasons. But we may yet implement this. Thanks! Andrew On Sep 30, 2009, at 6:26 AM, kef wrote: > > Hello, > > I am currently working on an AJAX application (prototype 1.6.1). As > usual, it runs very well on Chrome and Firefox but we encounter > difficulties, particularly with Internet Explorer 6. > > After much research, it appears that the problem is related to the > "memory leak". In fact, i reload only some parts of page. (I keep > always the header and footer) so a large part of the memory used is > never released. > > I found a solution partially responsive to my needs but it involves > changing the core prototype. Prior to Ajax call, I clean all events on > elements will be replaced (like _destroyCache during the unload of > window). > > There may be a cleaner solution but I have not found. > > My changes here: > remove: function (element) ( > / / Begin Fix > if (element = $ (element)) > element.stopObserving (false, true); > / / End Fix > element.parentNode.removeChild (element); > return element; > ) > > stopObserving function (element, eventName, handler) ( > element = $ (element); > > / / Begin Fix > if (handler === true) ( > for (var i = 0, length = CACHE.length; i <length; i + +) > if (CACHE [i]. descendantOf > CACHE & & [i]. DescendantOf (element)) ( > Event.stopObserving (CACHE [i], eventName); > CACHE [i] = undefined; > ) > CACHE = CACHE.reject (Object.isUndefined); > ) > / / End Fix > .... > ) > > In view of the evolution of AJAX and implementation of Internet > Explorer browsers, I think it may be advisable to incorporate a > equivalent system in core of prototype. > > Regards, Franck > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to email@example.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---