我怎样才能获得引用计数为托管对象?数为、对象

2023-09-06 09:29:56 作者:安若浅溪

.NET分析器可以显示引用计数管理对象。他们怎么算呢?

.NET profilers can show reference count to managed objects. How do they count them?

推荐答案

他们使用非托管的API可抵达探查。

They use unmanaged APIs which provide access to the profiler.

ICorProfilerCallback 和的 ICorProfilerCallback2 是主要的。这些都是是.NET廓线仪所使用的接口。还有像这个。

ICorProfilerCallback and ICorProfilerCallback2 are the main ones. These are the the interfaces that .NET profilers use. There are some more references like this.

您可以使用该方法的类加载(ClassLoadFinished())和卸载(ClassUnloadFinished())来跟踪这些信息。

You can use the methods for class loads (ClassLoadFinished()) and unloads (ClassUnloadFinished()) to track this information.