如何列出GC完成列表中的所有对象? [英] How to list all object in GC finalization list?
问题描述
我的程序崩溃了,它是VS的可视化工具,所以它很难调试它,我试图做出转储并使用WinDbg来研究它,但它不成功。
所以,现在我尝试以编程方式将我的手放在该列表上,但我不知道如何。感谢。
我不认为有一种方法可以通过.NET的托管框架类库获得终止队列FCL)。我怀疑如果你想以
查看 ICORDebugGCReferenceEnum
COM界面。您可以通过 ICorDebugProcess5 :: EnumerateGCReferences
:
提供一个枚举器
填充的集合中的对象中的 / usr / library / hh387794.aspxrel =nofollow noreferrertitle =MSDN reference page>
COR_GC_REFERENCE
[ICorDebugGCReferenceEnum ::
- 所有托管堆栈中的对象,包括托管代码中的实时引用以及公共语言运行库创建的对象。
> 来自手柄表的物体。这包括强引用(HNDTYPE_STRONG
和HNDTYPE_REFCOUNT
)和模块中的静态变量。
来自终结器队列的对象。终结器队列根对象,直到终结器运行。
(超链接和强调由我添加。)
枚举器返回的每个对象都有一个字段 type
。您可能需要筛选该字段与该值匹配的对象 CorGCReferenceType.CorReferenceFinalizer
。
I have crash in my program, it is a visualizer for VS, so, it is very hard to debug it, i have tried to make dump and use WinDbg to study it, but it unsuccessful.
So, now i try to put my hands on that list programmatically, but i don't know how. Thanks.
I do not think that there is a way to get at the finalization queue via .NET's managed Framework Class Library (FCL). I suspect that if you want to do this programmatically instead of debugging with WinDbg, you (just like WinDbg and similar tools) will need to use the CLR's unmanaged debugging & profiling APIs towards that end.
Take a look at the ICORDebugGCReferenceEnum
COM interface. You can retrieve on object of that type via ICorDebugProcess5::EnumerateGCReferences
:
"Provides an enumerator for objects that will be garbage-collected."
"The
COR_GC_REFERENCE
objects in the collection populated by [theICorDebugGCReferenceEnum::Next
method] represent three kinds of objects:
Objects from all managed stacks. This includes live references in managed code as well as objects created by the common language runtime.
Objects from the handle table. This includes strong references (
HNDTYPE_STRONG
andHNDTYPE_REFCOUNT
) and static variables in a module.Objects from the finalizer queue. The finalizer queue roots objects until the finalizer has run."
(Hyperlinks and emphasis added by me.)
Each object returned by the enumerator has a field type
. You might want to filter for objects where that field matches the value CorGCReferenceType.CorReferenceFinalizer
.
这篇关于如何列出GC完成列表中的所有对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!