【问题标题】:ExtJs component cleanupExtJs 组件清理
【发布时间】:2015-06-02 10:00:44
【问题描述】:

我在 ExtJs-in-action 中阅读了以下评论 -

'Do not dismiss the destruction portion of a Component’s lifecycle if you plan on developing your own custom
Components. Many developers have gotten into trouble when they’ve ignored this crucial step and have code that
has left artifacts such as data Stores that continuously poll web servers...'

我从未在 3.4.x 中对我的容器/组件调用显式析构函数/销毁
虽然事情似乎很好 - 我很好奇 1. 在哪些情况下实现析构函数变得必不可少
2.在关闭浏览器实例时处理组件销毁的正确约定是什么。

【问题讨论】:

    标签: extjs extjs3


    【解决方案1】:

    这个guide 可能是一本好书。

    您应该始终考虑在需要释放内存后清理对象,尤其是取消绑定事件侦听器和您使用setInterval 创建的任何计时器。一旦对象引用被销毁,您将无法访问它,但它仍可能正在侦听或触发事件并耗尽资源。

    一般在 ExtJs 中,你会在 destroy 方法中释放资源,但只要记住也要调用 callParent() 函数,以便 ExtJs 自己进行清理。

    这是 2012 年来自 IBM 的另一个 article,似乎更深入地探讨了这个主题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-28
      • 2012-08-03
      • 2021-05-05
      相关资源
      最近更新 更多