I'm writing a JQuery UI widget that encapsulates Google Map v3 that is custom-tailored for my large web application. In that widget, there are a couple of google.maps.*
objects being instantiated (and assigned to some this.variable
) such as the Map object, Marker, LatLn开发者_JS百科g etc.
The widget might be instantiated and destroyed many times on the same page due to the nature of the web application so it seems appropriate to take special care of the destroy()
to clean up stuff from soon-to-be-deleted instance.
So, the question is: do I need to specifically delete
the google.maps.*
objects from within the destroy()
method, or do they just turn orphaned and eventually garbage-collected by the engine as it goes along?
Or perhaps more generally in any Javascript code (jQuery or not), do I need to do a delete
before re-assigning a variable to another new someObject()
instantiation? Or will the engine automatically garbage-collect it?
精彩评论