Guys,
I am interested to find out how many objects were reclaimed by the garbage collector after I run the following code.
if (ObjectsOutstanding > GCThreshold) {
System.GC.Collect();
}
Could you please help me out with this one?
Guys,
I am interested to find out how many objects were reclaimed by the garbage collector after I run the following code.
if (ObjectsOutstanding > GCThreshold) {
System.GC.Collect();
}
Could you please help me out with this one?
In the Visual Studio debugger you can use the SOS library in the immediate window. There are several GC methods that give you the information you need. I don't know if this is what you want, but it is a starting point.
One easy way of doing this for your own custom-types would be to increment and track some counter in their finalizers.
e.g.
public class MyCustomType
{
public static int NumFinalizersCalled;
~MyCustomType()
{
Interlocked.Increment(ref NumFinalizersCalled);
}
}