On Wed, Jun 16, 2010 at 4:46 PM, Leonid Rozenblyum <[email protected]>wrote:

> Google Map API doesn't clearly states what will be if:
> a) create marker for the map;
> b) attach event listener to the marker
> c) setMap(null) - so delete marker from map;
> d) remove reference to the marker from internal array.
>
> Will it be memory leak here because event listener was connected to
> the marker?
>

There will be no memory leak.  If your event listener is connected to a
marker, *but that marker is otherwise free to be garbage collected*, then
the event listener will not prevent your marker from being garbage
collected.

Of course, you must take the usual care to ensure that your marker is free
to be garbage-collected.  It cannot be referenced from any other JavaScript
Object, Array, or Function (closure).

 Should we preserve listener during add, and remove it as well to
> ensure memory is really cleared or setMap(null) does this as well?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to