Thanks for solution.
There is no memory leaks anymore on IE7 and some leaks disappeared
also on IE6. I think you are on the half way and you should test your
program also on IE6, which is still widely useful browser.

GPDE's "Javascript memory leaks detector" finds two type of leaks
probably caused by Prototype:
1. element._prototypeEventID marked as memory leak (circular
reference)
2. All element properties extended by Prototype marked as memory leaks

By doing ...

    for (var id in cache){
      for (var eventName in cache[id]){
                cache[id][eventName].each(function(wrapper) {
                        Event.stopObserving(wrapper.element, eventName, 
wrapper.handler);
+                       wrapper.element._prototypeEventID = null;
                });
                cache[id][eventName] = null;
          }
    }

... removes all leaks of type 1 but causes lots of other leaks of type
2.

On Jan 18, 9:06 pm, mr_justin <gro...@jperkins.otherinbox.com> wrote:
> 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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to