【发布时间】:2011-01-18 10:31:20
【问题描述】:
当我们分析内存堆时,我们一般会遇到以下 4 种类型的 GC 句柄:
弱:- 弱 GC 句柄不会阻止它对应的实例被垃圾回收。
Example, used by the System.WeakReference class instances.正常:- 正常的 GC 句柄可防止相应的实例被垃圾回收。
Example, used by the instances of strong references。RefCounted:- 引用计数的 GC 句柄在运行时内部使用,
example, when dealing with COM interfaces.Pinned:- 为什么我们需要这种 GC 句柄?只是为了避免该实例在内存中的移动还是
is there any other notion behind this? I want to know the notion behind Pinned GC handle(with an example).
为 Itay 的答案编辑:- 我有一个非空数组-DiffCell[][] 绑定到数据网格WPF。当我关闭存在此数据网格的窗口时,在堆上我看到 Pinned GC 句柄 通过 DiffCell 指向这个空数组>object[](见快照)。 I am not using any unsafe code. I am just setting ItemsSource of data grid to null before closing that window. So my question is who does pin this array on heap and why?
【问题讨论】:
标签: .net wpf garbage-collection