This is a C# (v3.0) Winforms problem.
这是一个C#(v3.0)Winforms问题。
I have a big object that is associated with a BindingSource. When I have done with this object and the BindingSource, I want to remove the reference from the BindingSource so the object can be released. I used BindingSource.Clear(). But after that, in the memory profiler, I can still see the object alive and the only reference is from the BindingSource.lastCurrentItem.
我有一个与BindingSource相关联的大对象。当我完成这个对象和BindingSource时,我想从BindingSource中删除引用,以便可以释放该对象。我使用了BindingSource.Clear()。但在那之后,在内存分析器中,我仍然可以看到对象存活,唯一的引用来自BindingSource.lastCurrentItem。
My question is, how should I remove the reference from the BindingSource? Thanks.
我的问题是,我该如何从BindingSource中删除引用?谢谢。
1 个解决方案
#1
What happens when you set BindingSource.DataSource = null
?
设置BindingSource.DataSource = null后会发生什么?
BindingSource.Clear()
clears all elements in the underlying list (BindingSource.List
), but doesn't remove the reference to the data source. (Reference)
BindingSource.Clear()清除基础列表中的所有元素(BindingSource.List),但不删除对数据源的引用。 (参考)
#1
What happens when you set BindingSource.DataSource = null
?
设置BindingSource.DataSource = null后会发生什么?
BindingSource.Clear()
clears all elements in the underlying list (BindingSource.List
), but doesn't remove the reference to the data source. (Reference)
BindingSource.Clear()清除基础列表中的所有元素(BindingSource.List),但不删除对数据源的引用。 (参考)