[OpenLayers-Users] IE memory leaks

Deli Soetiawan crushfire2004 at gmail.com
Wed Oct 8 21:26:32 EDT 2008



lukast wrote:
> 
> 
> Thanks, but what you mean destroying and recreating using body onload
> event ?
> invoke map.destroy() ?
> And why body.onload ? Now I am initializing the map simply invoking OL api
> methods inside body:
> 
> <body>
> ...
> initializeMap(); // and this functions initializes my map
> ....
> </body>
> 

lukast wrote:
> Every time I am refreshing the page with the map, memory rapidly increases
your problem only leaks everytime you refresh your web page (clicking
refresh button right?), so body onload would be sufficient.

i think you can do some function to destroy the map using <body
onunload="javascript:map.destroy();"> and initialize map on <body
onunload="javascript:initializeMap();"> or in JS you could use
windows.onload and windows.onunload.

if you want to use initializeMap(); on body it didn't matter just add
map.destroy() to it, something like
function initializeMap(){
  try{
    map.destroy;
  }
  catch(e){} //ignore the error
  ........ //create your map or call function for it
}

further you can check if "map" object is defined using if statement, i'm not
experience JS programmer so that maybe just rough idea.

the idea will make sure your map (div layers) wouldn't stacks every page
refresh because you destroy and reinitialize the map, IE don't do well with
destroying JS object so it stack every you create/recreate the object again,
thats why you need to destroy your map first
-- 
View this message in context: http://www.nabble.com/IE-memory-leaks-tp19859508p19890687.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list