开发者

Flex ArrayCollection: RemoveAll() vs new ArrayCollection

When would you want to use removeAll() vs开发者_如何学编程 just new ArrayCollection when you want to clear an array collection.

Remove all iterates though each item in the list. I can't see a case when I would want to use it.


You'd probably want to use removeAll in the case where the ArrayCollection contains items with a propertyChange event dispatcher attached to them (with bindings?). The removeAll will clean these events nicely for you.

However, if you use new ArrayCollection the old ArrayCollection will be deallocated from the reference, but may never be garbage collected, because it still has references attached. This could potentially lead to memory leaks.


Note that removeAll() will not in fact remove ALL elements from collection in case a filterFunction is defined and applied (.refresh()) and there are any elements in source Array, rejected by this filter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜