Reputation: 306
We are asking from deferred a promise, register callback on it, and never destroy this object or clean the callback. Who is manage the promise life cycle (Who is destroy it)? Who (and how) is manage the deffered life cycle? What about memory-leaks?
Thanks!
Upvotes: 2
Views: 1810
Reputation: 276306
This depends on the promise implementation.
I've answered this question for Angular promises in particular, however the conclusions from there generally apply to other implementations as well.
Basically, you have nothing to worry about with reasonable promise implementations, the garbage collector will detect when your promise goes "out of scope" and there are no references to it and deallocates it.
Upvotes: 3