知识卡片

普通读书笔记卡 · 1872.b.10

观察者需治理订阅生命周期

理解等级:高级

主题变化后通知已注册观察者,使同一功能可绑定多个视图且运行时更换。观察者必须注销,否则既可能保留内存,也让失效视图继续被调用。主题细粒度变化而界面只需粗粒度更新时,每个观察者重复判断会浪费资源,应考虑通知粒度与实际呈现需要。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 易用性 · 查看原书依据

      If observers neglect to de-register, then their memory is never freed, which effectively results in a memory leak. In addition, this can negatively affect performance, since obsolete observers will continue to be invoked.

    参考来源

    - 位置:《Software Architecture in Practice, 4th Edition》第13章《易用性》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch13.html) - 结论依据:所引连续原文给出本卡机制或取舍;条件与示例结合本节已读上下文解释。 - 原始内容:If observers neglect to de-register, then their memory is never freed, which effectively results in a memory leak. In addition, this can negatively affect performance, since obsolete observers will continue to be invoked.