using System;
public class MyClass {
public void Dispose() {
Console.WriteLine("Dispose()");
GC.SuppressFinalize(this);
}
}
public class ReRegFinalApp {
public static void DoSomething() {
MyClass t = new MyClass();
Console.WriteLine(t);
t.Dispose();
GC.ReRegisterForFinalize(t);
}
public static void Main(string[] args) {
long n = GC.GetTotalMemory(true);
Console.WriteLine("start of Main: {0} bytes allocated", n);
DoSomething();
n = GC.GetTotalMemory(true);
Console.WriteLine("end of Main: {0} bytes allocated", n);
}
}
|