一旦组件被销毁或这些存储是否被垃圾回收,在initComponent函数内存中创建的存储是否会被泄漏? [英] Are Stores created in the initComponent function memory leaks once the component is destroyed or will these stores be garbage collected?

查看:122
本文介绍了一旦组件被销毁或这些存储是否被垃圾回收,在initComponent函数内存中创建的存储是否会被泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个从另一个飙升的问题:



在ExtJS 4中拥有相同视图和多次存储的最佳做法



因此,在网格的initComponent函数中创建存储的场景中。



我应该覆盖网格的onDestroy还可以销毁商店吗?



解决方案



  1. 不,商店在销毁网格后仍然存在

  2. 不,您不需要覆盖网格的销毁方法


您可以通过设置 autoDestroy 标记为 true API-Link


  autoDestroy:Boolean 

当只有一个DataView使用商店时,只能存在
,查看,然后将autoDestroy标志配置为
true。这导致视图的破坏触发其商店的
销毁。

 默认为:false 


看到这个工作演示,用于网格使用的商店上的 autoDestroy 的效果(关闭演示中的网格) p>

附加信息:


  1. 始终使用 storeId

  2. 使用 StoreManager 查找商店的存在


This is a question that surged from this other one:

Best practice to have the same view and store multiple times in ExtJS 4

So in a scenario where stores are created in the initComponent function of a grid.

Should I override onDestroy of the grid to also destroy the store ?

Or these stores would be garbage collected because simply there are no references to them?

解决方案

  1. No, the store will still exist after destroying the Grid
  2. No, you will not need to override the destroy method of the grid

You can force the store to destroy itself by setting it's autoDestroy flag to true API-Link

autoDestroy : Boolean

When a Store is used by only one DataView, and should only exist for the lifetime of that view, then configure the autoDestroy flag as true. This causes the destruction of the view to trigger the destruction of its Store.

Defaults to: false

See this working demo for the effect of autoDestroy on a store that is used by a grid (close the grids in the demo)

Additional info:

  1. Always use a storeId
  2. Use the StoreManager to lookup the existence of a store

这篇关于一旦组件被销毁或这些存储是否被垃圾回收,在initComponent函数内存中创建的存储是否会被泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆