How can I get reference count for a managed object?

风格不统一 提交于 2019-12-11 03:48:22

问题


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


回答1:


They use unmanaged APIs which provide access to the profiler.

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

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



来源:https://stackoverflow.com/questions/1471205/how-can-i-get-reference-count-for-a-managed-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!