[OpenLayers-Users] Re moved markers still occupy memory :/
lukast
lukast at poczta.fm
Thu Aug 7 06:46:41 EDT 2008
Has anyone aony idea ? I would appreciate any help..
lukast wrote:
>
> Hi,
>
> I've got memory usage problem with OpenLayers 2.6 in IE 6. Memory seems to
> slowly but instantly increase when using the map. I am using Drip 0.5 to
> detect memory leaks - but it shows no memory leaks since I have installed
> Windows SP3.
>
> Apart from this I have got another problem with memory usage connected
> with markers. I dynamically add several markers to the markers layer.
> Memory increases very fast when I add Markers - 20 Markers - aproximatelly
> 10MB of RAM :(
> Also when I remove these markers from the map memory stays on the same
> level - but should be freed.
> Here is the way I add markers to the map this way:
>
> //icon initialization - only once for all markers
> var iconSize = new OpenLayers.Size(20,20);
> var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h);
> localizationIcon = new
> OpenLayers.Icon(icon.localizationIcon,iconSize,iconOffset);
>
> //add single marker
>
> var currentIcon = localizationIcon.clone();
> this.currentMarkers[index] = new OpenLayers.Marker(new
> OpenLayers.LonLat(poi.x,poi.y),currentIcon);
>
> //add popup for this marker
>
> this.currentMarkers[index].events.register('mouseover',
> this.currentMarkers[index], function(evt) {
>
> var contentDiv = "<div style=\"font-size: 12px;color:
> blue\">"+title+"</br>"+content+"</div>";
>
> var popup = new OpenLayers.Popup.Anchored("chicken",
> new
> OpenLayers.LonLat(poi.x,poi.y),
> new
> OpenLayers.Size(250,60),contentDiv,currentIcon,false);
> searchManager.currentPopup = popup;
> localizationLayer.map.addPopup(searchManager.currentPopup,true);
> searchManager.currentPopup.show();
> OpenLayers.Event.stop(evt);
> });
> this.currentMarkers[index].events.register('mouseout',
> this.currentMarkers[index], function(evt) {
> map.removePopup(searchManager.currentPopup);
> searchManager.currentPopup.destroy();
> searchManager.currentPopup = null;
> OpenLayers.Event.stop(evt);
> });
>
> //add new marker to the markers layer
> localizationLayer.addMarker(this.currentMarkers[index]);
>
>
> Removing markers looks like this:
>
> for(i=0;i<this.currentMarkers.length;i++){
> localizationLayer.removeMarker(this.currentMarkers[i]);
> this.currentMarkers[i].destroy();
> }
> $(this.currentMarkers).clear();
>
> What is wrong with that code ?
>
> Appreciate any help.
>
> Best Regards,
> lukast
>
>
--
View this message in context: http://www.nabble.com/Removed-markers-still-occupy-memory-%3A--tp18866082p18867892.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list