[OpenLayers-Users] Re moved markers still occupy memory :/

Eric Lemoine eric.c2c at gmail.com
Fri Aug 8 01:19:56 EDT 2008


I also did observe memory leaks with the markers layer a while back.
Some correction even made it into trunk but it didn't solve the
problem entirely. Why dont you open a ticket with an example
demonstrating the problem? Regards. Eric

2008/8/7, lukast <lukast at poczta.fm>:
>
> Thanks for quick reply !
>
> I have used png icons, but had image hack disabled:
> OpenLayers.Util.alphaHack = function() { return false; }
> Now I converted my marker icon to gif, but unfortunatelly it did not help :/
> Every time I add some markers memory increases (ok, that is normal), but
> when I remove these markers from markers layer and then invoke destroy
> method on ebery marker memory is not relesed :/
> Maybe Marker.destroy() method does not work correctly ?
>
>
>
>
> 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--tp18866082p18870036.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list