[OpenLayers-Users] Markers' events memory leak?

Christopher Schmidt crschmidt at metacarta.com
Fri Feb 16 08:33:24 EST 2007


On Thu, Feb 15, 2007 at 09:29:11PM -0800, Donal wrote:
> 
> I hope that some might find this useful.
> 
> I found the following function at http://dev.rubyonrails.org/ticket/5198
> 
> // Remove all event handlers from an element
>   stopObservingElement: function (element) {
>     if (! Event.observers) return;
>       for (var i = 0; i < Event.observers.length; ) {
>         if (element == Event.observers[i][0]) {
>           Event.stopObserving.apply (this, Event.observers[i]);
>           Event.observers.splice (i, 1);
>         }
>         else
>           i++;
>       }
>    }
> 
> I added this function to the OpenLayers.Event class.
> 
> I now can call OpenLayers.Event.stopObservingElement(this.imageDiv); in the
> icon destroy() method and the memory leak is kept in check.

Donal: 

Great! I had seen many reports about memory usage, some in the use of
markers, and had not had time to look into it. I will open a ticket and
make sure that this gets looked at for addition in 2.4. If you want to
create a patch of your differences between SVN and your changed version,
and add it to:
 
  http://trac.openlayers.org/ticket/369

that would be great.

(This is probably having a huge affect on some of the applications that
I am personally interested in, so I'm looking forward to getting this
fix in.)

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list