We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.什么是内存泄露
链接 链接
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1.什么是内存泄露
4类常见内存泄漏:
1、意外的全局变量
解决办法在 JavaScript 文件头部加上 'use strict',使用严格模式避免意外的全局变量,此时上例中的this指向undefined。如果必须使用全局变量存储大量数据时,确保用完以后把它设置为 null 或者重新定义。
2.被遗忘的计时器或回调函数
解决办法:现代的浏览器(包括 IE 和 Microsoft Edge)使用了更先进的垃圾回收算法(标记清除),已经可以正确检测和处理循环引用了。即回收节点内存时,不必非要调用 removeEventListener 了。
3、脱离 DOM 的引用
4、闭包
使用后给变量复制null
5.事件监听: 没有正确销毁 (低版本浏览器可能出现)
链接
链接
The text was updated successfully, but these errors were encountered: