Get Total Memory : Garbage Collection : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Garbage Collection »

 

Get Total Memory








    
 
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);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Garbage Collection