Why does GC.GetTotalMemory() report huge memory allocations?

Posted by Seventh Element on Stack Overflow See other posts from Stack Overflow or by Seventh Element
Published on 2010-04-02T11:21:05Z Indexed on 2010/04/02 11:23 UTC
Read the original article Hit count: 157

Filed under:
|

I have been playing around with GC.GetTotalMemory(). When I create a local variable of type Titles in the example below, the consumed amount of memory increases by 6276 bytes. What's going on here?

class Program
{
    enum Titles { Mr, Ms, Mrs, Dr };

    static void Main(string[] args)
    {
        GetTotalMemory();
        Titles t = Titles.Dr;
        GetTotalMemory();
    }

    static void GetTotalMemory()
    {
        long bytes = GC.GetTotalMemory(true);
        Console.WriteLine("{0}", bytes);
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET