[OpenLayers-Trac] [OpenLayers] #1123: OpenLayers.Layer.Markers.destroy() should destroy its markers
OpenLayers
trac at openlayers.org
Fri Nov 16 14:08:39 EST 2007
#1123: OpenLayers.Layer.Markers.destroy() should destroy its markers
----------------------------+-----------------------------------------------
Reporter: ahocevar | Owner: euzuro
Type: bug | Status: new
Priority: minor | Milestone: 2.6 Release
Component: Layer.Markers | Version: 2.5
Resolution: | Keywords: review
----------------------------+-----------------------------------------------
Comment (by euzuro):
In theory, I like what this patch is doing.
With OpenLayers, however, we have always followed a strict model of "you
create it, you destroy it", which is the issue that I have with this
patch.
As I've been trained, the easiest way to keep a program's memory usage
clean and efficient is to always make sure each allocation is paired with
a freeing (in this case each "new" is paired with a call to destroy() and
either a "delete" or setting to null to kill the reference).
In this case, the markers layer is not *creating* the markers. Rather, the
markers are created outside the layer class and then added via
addMarker(). Personally, I think it would have been *much* easier to
simply make a createMarker() function on the !OpenLayers.Layer.Marker
class, but alas, this has not been the model.... as far as I have been
concerned.
Whether or not people agree with this is of course up to debate, I'm only
expressing my personal philosophy. :-)
--
Ticket URL: <http://trac.openlayers.org/ticket/1123#comment:3>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list