Closed katharinekerr closed 4 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This does not mean that the issue is invalid. Valid issues may be reopened.
Thank you for your contributions.
This is a (check one box):
My version of UI-Router is: 1.0.22
Bug Report
Current Behavior:
If you have a resolve object that references the
$scope
and the state ($state.reload()
) is reloaded, the old$scope
object will remain in memory.This causes a memory leak, as each time you reload the state the old
$scope
(s) remain.It seems like this is happening because there remains a reference to the
$resolve
object (which contains the reference to the$scope
) by thetransitionHistory
orsuccessfulTransition
objects: https://github.com/ui-router/core/blob/9bb728700e743ea27d90873956f8120836ecae44/src/globals.ts#L51.Expected Behavior:
I'm not certain that a resolve should be used in this way (although we are doing it :P). Is it reasonable to reference the
$scope
on a resolve?If so, it would be great to clean up the
$scope
reference. I've added a version of this clean up in the Plunker, that can be commented out to see the issue disappear.Link to Plunker or stackblitz that reproduces the issue:
https://plnkr.co/edit/eI9IsmI9JCSMGgcKONMD?p=preview
I was having troubles profiling the memory usage through Plunker, so I'd suggest creating an
index.html
file locally. When profiling the memory via chrome, if you reload the state multiple times, you can see that the "FooA" object remains for each press of the button.