OK, so it looks like we found the leak. It was in Prototype's
destroyCache method that is registered to the window unload event in
IE only.
As I mentioned before, the Event-related code has changed quite a bit
from what's in the publicly available 1.6.0.3 vs. what's at the head
of the git repository (still called 1.6.0.3). I've actually found that
both code bases need to be patched. In the head of the repository,
Event.stopObserving is called on each element in the cache BUT those
elements are not null'd out after stop observing. Conversely, in the
public downloadable version, Event.stopObserving is NOT called on each
element BUT those elements are null'd out.
Based on our testing, both Event.stopObserving(CACHE[i]) and CACHE[i]
= null is required for adequate cleanup and to avoid memory leaks. I
also added the bit to clear out the Element cache as well for good
measure. Below is a diff that can be applied to the publicly
downloadable 1.6.0.3. This diff can easily be modified to work for the
Event code that is in the git repository.
Begin
patch---------------------------------------------------------------------------------------------------------
Index: /Users/justin/src/***/javascripts/prototype.js
===================================================================
--- /Users/justin/src/***/javascripts/prototype.js (revision xxxxxx)
+++ /Users/justin/src/***/javascripts/prototype.js (working copy)
@@ -3967,6 +3967,7 @@
};
wrapper.handler = handler;
+ wrapper.element = element;
c.push(wrapper);
return wrapper;
}
@@ -3983,9 +3984,16 @@
}
function destroyCache() {
- for (var id in cache)
- for (var eventName in cache[id])
+ for (var id in cache){
+ for (var eventName in cache[id]){
+ cache[id][eventName].each(function(wrapper) {
+ Event.stopObserving(wrapper.element, eventName,
wrapper.handler);
+ });
cache[id][eventName] = null;
+ }
+ }
+
+ for(var id in Element.cache) Element.cache[id] = null;
}
End
patch---------------------------------------------------------------------------
Hope this helps.
-justin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---