Home  >  Article  >  Web Front-end  >  A brief discussion on the memory leak problem caused by js closure_javascript skills

A brief discussion on the memory leak problem caused by js closure_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:53:381424browse

In js closures, "local variables" can be defined, but calling them externally, especially repeated assignment calls, will cause a lot of memory overhead. How to prevent this phenomenon from happening? Are there any similar memory or efficiency issues to be aware of regarding closures? How to avoid it?

Memory problems may be caused by the following reasons:
1. Circular reference causes memory leak
2. Memory leak caused by external function call

Avoid memory leaks

1. Break circular references
2. Add another closure
3. Avoid closure itself

The above is the entire content of this article, I hope you all like it.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn