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

Carousel causes a memory leak. #1414

Closed
joshkurz opened this issue Dec 15, 2013 · 2 comments
Closed

Carousel causes a memory leak. #1414

joshkurz opened this issue Dec 15, 2013 · 2 comments

Comments

@joshkurz
Copy link
Contributor

The carousel in its current form causes a memory leak due to how it uses $timeout.

If the carousel's scope is destroyed, then the timeout that moves the carousel forward is still ran even though there is no carousel in the DOM and the Scope has been destroyed.

Here is an example. http://plnkr.co/edit/RyZpy2IvZFM3mMmxQ2kY?p=preview
If you click on the splice button twice it will remove both of the carousels and then if you look in the console, the print statement is still ran even though there is no carousel.

The fix is to cancel the timeout right before the carousel sets a new one and to cancel it also during the $destroy event.
http://plnkr.co/edit/E2cAbH2VocvqbNorjlDv?p=preview

I can create a PR for this if you believe it is a problem.

@bekos
Copy link
Contributor

bekos commented Dec 16, 2013

@joshkurz This is definitely a bug and as such, also a problem :-)
The proposed solution seems right and of course a PR from you is more than welcomed!!!

@joshkurz
Copy link
Contributor Author

thanks @bekos

Ill get one together and send it in.

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

Successfully merging a pull request may close this issue.

2 participants