C# - 它是可能遍历GC堆? [英] C# - Is it Possible to Iterate GC Heap?

查看:177
本文介绍了C# - 它是可能遍历GC堆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道以下问题是否valid.To教育自己我只是问。

I'm not sure whether the following questions are valid.To educate myself i am just asking.

(1)我可以以编程方式遍历所有GC堆代?

( 1 ) Can I programmatically iterate the GC Heap of all generations ?

(2)是否有可能看如何在GC上我的组装操作通过启动一个线程?

( 2 ) Is it possible to watch how does the GC operate on my assembly by launching a thread ?

推荐答案

要你问题的答案是:


  1. 不幸的是,不,你不能。 CLR的垃圾收集工作在一个标记,扫,紧凑的图案,从而在运行之间没有关于堆的信息,它会让你遍历中的所有对象(除堆或电流产生一个特定类型的实例的大小等)吧。

  1. Unfortunately no, you cannot. The CLR's garbage collector works in a mark, sweep, compact pattern so in between runs there is no information about the heap (other than size of the heap or the current generation of a specific type instance) that would allow you to iterate all objects in it.

监视GC的最好方法是使用的 的perfmon 并观看(或记录)的的 CLR内存计数器的。

The best way to monitor the GC is to use perfmon and watch (or log) the CLR memory counters.

这篇关于C# - 它是可能遍历GC堆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆