Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Parent context keeps a reference on destroyed children through closures #4298

Closed
yoann-antoviaque opened this issue Aug 28, 2015 · 3 comments

Comments

@yoann-antoviaque
Copy link
Contributor

While looking for memory leaks in our application I noticed references to destroyed contexts, preventing them from being garbage collected:

line 2149:
$scope.$on('$destroy', function() {
scope.$destroy();
});
line 4805:
var scope = originalScope.$new();
originalScope.$on('$destroy', function(){
scope.$destroy();
});
both keep a reference to child scope, those listener should be removed when child scope is destroyed:
var offDestroy = $scope.$on('$destroy', function() {
scope.$destroy();
});
scope.$on("$destroy", offDestroy);
and
var offDestroy = originalScope.$on('$destroy', function(){
scope.$destroy();
});
scope.$on('$destroy', offDestroy);

@pkozlowski-opensource
Copy link
Member

line 2149:

Line numbers are not very helpful without knowing which version you are using :-(
Would be good to provide more context: https://github.com/angular-ui/bootstrap/blob/master/CONTRIBUTING.md#you-think-youve-found-a-bug

How about sending a pull request to this repo since you've got already the issue identified?

@yoann-antoviaque
Copy link
Contributor Author

Sorry I forgot the version number... I was referencing the latest but will send a pull request

@yoann-antoviaque
Copy link
Contributor Author

pull request: #4299

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

No branches or pull requests

3 participants