[英]How to resolve angular memory leak
In order to optimize Garbage Collector manually, how can we forcefully push variables to the garbage collector? 为了手动优化垃圾收集器,我们如何强制将变量推入垃圾收集器? Like if we have a root/global level variable in one angular component, and then when we are switching from that page to another - we won't need the global variables in that page?
就像我们在一个角度分量中有一个根/全局水平变量,然后当我们从该页面切换到另一个页面时一样-我们将不需要该页面中的全局变量吗? How can we move to garbage collector?
我们如何才能转移到垃圾收集器?
If we do variable = null or variable = undefined on ngOnDestroy() like we unsubscribe from observables, would that help? 如果我们像取消订阅Observables一样对ngOnDestroy()进行变量= null或变量= undefined的定义,这会有所帮助吗?
Strategies to prevent leaks 防止泄漏的策略
Nullify all references to models in a component on the component $destroy phase 在组件$ destroy阶段取消对组件中所有模型的引用
Try to remove all circular dependencies by using yet another layer of indirection 尝试通过使用另一层间接删除所有循环依赖项
Create a this.state object to manage the instance state in a place for easier nullification 创建一个this.state对象以管理实例状态,以便更轻松地进行无效化
Dispose subscriptions 处置订阅
Examine third party software and decide to use it or not also based on memory problems or contribute with PRs 检查第三方软件并根据内存问题决定是否使用它,或者与PR一起提供帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.