[OpenLayers-Users] OpenLayers.Class destroy method question
laurentK2
lboileau at k2geospatial.com
Fri Nov 11 11:48:28 EST 2011
I'm developping my own classes using the "OpenLayers.Class" class. However,
I'm wondering something regarding the destroy method.
I created my own class that doesn't inherit from any other. That class has a
few properties with values and initialize and destroy methods among others.
In my destroy method, I assign null values to my properties to prevent
memory leaks. Here's something that looks like it:
ExampleClass = OpenLayers.Class(
{
property: "defaultValue",
initialize: function(options)
{
// Do Stuff
},
destroy: function()
{
// Do Stuff
this.property = null;
},
CLASS_NAME: "ExampleClass"
});
I assumed that calling the destroy method on an object of that class would
clear that object's properties. However, it seems that the destroy call will
nullify the assigned properties of the "OpenLayers.Class" object. That means
that every new instance of the class won't have the defaultly assigned
property.
Example:
var obj = new ExampleClass(); // obj will have its property to
"defaultValue"
obj.destroy(); // Destroy the obj instance.
var obj2 = new ExampleClass(); // obj will have its property nullified!
Could anyone tell me how to proceed so that destroy() will nullify the
instantiated object property instead of nullifying that class's property.
Help would be immensely appreciated. Thank you.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Class-destroy-method-question-tp6985999p6985999.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111111/de11e362/attachment.html
More information about the Users
mailing list