A brief discussion on memory leakage caused by js closures

  • 2020-06-19 09:40:58
  • OfStack

In the js closure, you can define "local variables," but external calls, especially repeated assignments, can cause a lot of memory overhead. How to prevent this phenomenon from happening? Are there any similar memory or efficiency issues to note about closures? How to avoid it?

Memory problems can be caused by:
1. Circular references cause a memory leak
2. Memory leaks caused by external function calls

Avoid memory leaks

1. Break circular references
2. Add another closure
3. Avoid closures themselves

This is the end of this article, I hope you enjoy it.


Related articles: