unloadCache Not available since 1.6.

3 views
Skip to first unread message

yohann.richard

unread,
Nov 28, 2007, 2:02:03 AM11/28/07
to Ruby on Rails: Spinoffs
Hi guys,

I just noticed that unloadCache has been removed from 1.6 without
further explanations.

Any idea why ? What happens to the MSIE memory leak problem ?

Did our javascript gurus found a way to avoid the leak during the
event registration ?

Cheers,

Y.R.

yohann.richard

unread,
Dec 3, 2007, 2:23:47 AM12/3/07
to Ruby on Rails: Spinoffs
bump

Ken Snyder

unread,
Dec 3, 2007, 10:13:31 AM12/3/07
to rubyonrail...@googlegroups.com
yohann.richard wrote:
> Hi guys,
>
> I just noticed that unloadCache has been removed from 1.6 without
> further explanations.
>
> Any idea why ? What happens to the MSIE memory leak problem ?
> ...
The functionality is still there--a private method called "destroyCache"
takes the place of Event#unloadCache (1.6.0 lines 3861-3869). The
method was always intended to be private, but with 1.6, many private
functions have been made truly private through the use of closures.

- Ken Snyder

kangax

unread,
Dec 3, 2007, 11:14:19 AM12/3/07
to Ruby on Rails: Spinoffs
>> "have been made truly private through the use of closures"

Which sometimes becomes a real pain when you want to work with Event's
cache, dom:loaded and other "private" methods...

Tuan

unread,
Dec 3, 2007, 11:32:54 AM12/3/07
to Ruby on Rails: Spinoffs
Oh man - yeah, the removal of this method really wreaks havoc on our
web app. We use UnloadCache() as part of our AJAX handling code - with
it gone, there's no way to wipe the slate clean with event handlers
for ajax loads. It's nice that it's called automatically on page
unload for IE, but what about for AJAX updates? I would looooooove for
this to be made public again! Until then, I guess we have to stick
with prototype 1.5 :(

-Tuan

Ryan Gahl

unread,
Dec 3, 2007, 12:18:48 PM12/3/07
to rubyonrail...@googlegroups.com
For quite a while, we have been using a wrapper class we call DOMEventCache. Our widgets each their own instance of this class, which has a dispose() method, so when the widget refreshes its UI, dispose is called, which (among other things) unloads it's own local dom events. I highly recommend undertaking this type of encapsulation if you are authoring complex long running AJAX apps.


http://www.nthpenguin.com
--
Architect
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire: 1-262-951-6727
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl

Ken Snyder

unread,
Dec 3, 2007, 12:32:26 PM12/3/07
to rubyonrail...@googlegroups.com
Tuan wrote:
> Oh man - yeah, the removal of this method really wreaks havoc on our
> web app. We use UnloadCache() as part of our AJAX handling code - with
> it gone, there's no way to wipe the slate clean with event handlers
> for ajax loads. It's nice that it's called automatically on page
> unload for IE, but what about for AJAX updates? I would looooooove for
> this to be made public again! Until then, I guess we have to stick
> with prototype 1.5 :(
>
> -Tuan
>
You can easily implement your own destroyCache function:

Event.unloadCache = function() {
for (var id in Event.cache)
for (var eventName in cache[id])
cache[id][eventName] = null;
};

Also, along those lines, I wonder if using Element#remove will clear up
any memory leaks. If not, Element#remove should be ramped up to detach
listeners. I'm thinking of Douglas Crockford's purge() function
(http://javascript.crockford.com/memory/leak.html) but I don't
understand the Prototype 1.6 Event code well enough--I could be way off
base.

- Ken Snyder

Tuan

unread,
Dec 3, 2007, 12:59:10 PM12/3/07
to Ruby on Rails: Spinoffs
Ken, Ryan - you guys are pretty sweet. In the long run I'll be moving
to the microsoft AJAX framework (ack!) and using their event
registration model to take care of this - but until then, I'll be
using Ryan's workaround - carpet bombs instead of scalpels for now :)

Cheers,
-Tuan

kangax

unread,
Dec 3, 2007, 4:19:37 PM12/3/07
to Ruby on Rails: Spinoffs
Ken,
destroyCache and all the event wrapper methods are exactly what I
meant by referring to private functions. It just doesn't feel right to
create duplication when all of this is already in the source (but is
encapsulated as a closure)

Ryan,
this is indeed a way to go. We at http://prototype-ui.com also give
each class-widget a destroy method for cleaning up observers.

best,
kangax

ex-lion-tamer

unread,
Dec 3, 2007, 4:37:11 PM12/3/07
to Ruby on Rails: Spinoffs
I also depended on unloadCache for complex pages, sorry to see it go.


On Dec 3, 4:19 pm, kangax <kan...@gmail.com> wrote:
> Ken,
> destroyCache and all the event wrapper methods are exactly what I
> meant by referring to private functions. It just doesn't feel right to
> create duplication when all of this is already in the source (but is
> encapsulated as a closure)
>
> Ryan,
> this is indeed a way to go. We athttp://prototype-ui.comalso give

Ken Snyder

unread,
Dec 3, 2007, 5:09:45 PM12/3/07
to rubyonrail...@googlegroups.com
I've sent a request on the prototype-core list that Event#unloadCache()
be made available again, even as soon as 1.6.1.

http://groups.google.com/group/prototype-core/browse_thread/thread/9bad712f70d327ea

- Ken Snyder

Reply all
Reply to author
Forward
0 new messages