[OpenLayers-Dev] Memory Leak in OpenLayers + IE

Christopher Schmidt crschmidt at metacarta.com
Tue Mar 27 11:48:38 EDT 2007


So, after some investigation this morning, I've discovered a source of a
memory leak in Internet Explorer + OpenLayers:


Currently, when creating Tile.Image images, we bind a load/error
listener:

 OpenLayers.Event.observe(image, "load",
               OpenLayers.Util.onImageLoad.bindAsEventListener(image));
 OpenLayers.Event.observe(image, "error",
               OpenLayers.Util.onImageLoadError.bindAsEventListener(image));

(Util.js, line ~180)

This is how we prevent tiles from displaying in the wrong location.
Unfortunately, this closure on the image is never cleaned up, so IE
doesn't destroy the images, even when the page is navigated away from,
resulting in a memory leak.

No fix yet, just documenting this so that if anyone has an obvious 'oh,
just do $foo', they can feel free to offer it up :)  

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list