Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

fix(markers): fix dom markers memory leaks#273

Merged
nmccready merged 1 commit intoangular-ui:masterfrom
ValentinH:fix-dom-markers-leaks
Jul 20, 2016
Merged

fix(markers): fix dom markers memory leaks#273
nmccready merged 1 commit intoangular-ui:masterfrom
ValentinH:fix-dom-markers-leaks

Conversation

@ValentinH
Copy link
Contributor

@ValentinH ValentinH commented Jul 18, 2016

I've added the dom markers feature a few months ago, and by playing with it again, I found out that there were memory leaks due to this feature. This PR solves them.

Demo of the feature: http://codepen.io/ValentinH/full/XKkEEd/

_create(newMarkers, oldMarkers);
});
scope.$on('$destroy', function () {
_destroy(leafletScope.markers, {}, leafletMarkers, map, layers);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should call deleteMarker on each leaflet marker when the directive is destroyed. Thus, we are sure that everything is reallyclean up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally this would make sense. But the markers are on the same scope as the map. So deleting the markers should already happen since the map is being removed.

map.remove();

Copy link
Contributor Author

@ValentinH ValentinH Jul 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, but if there is some cleaning to be done before removing the marker, then we might need to call the deleteMarker explicitly...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for merging it. I still have a question: in this line, we only delete the markers that are not anymore in the scope (if I understand correctly what _seeWhatWeAlreadyHave does). But if we destroy the directives, shouldn't we delete all the leaflet markers?

@nmccready
Copy link
Contributor

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants