title: Struct overhead of C# primitive type aliases?
body: <p>I noticed that the primitive types in C# are really just implemented as aliases to structs defined in the <code>System</code> namespace, e.g. <code>ulong</code> is an alias to the <code>System.UInt64</code>, which is of <code>struct</code> type. Is there any additional space-time overhead to the primitive types in C# arising from this? Say, does <code>ulong</code> really consume only 8 bytes of memory?</p>
  
  <p>In spirit, this should test the memory overhead:</p>
  
  <pre><code>using System;
  
  class Program
  {
      static void Main()
      {
          long beforeAlloc = GC.GetTotalMemory(false);
          ulong[] myArray = new ulong[System.Int32.MaxValue];
          myArray[0] = 1;
          long afterAlloc = GC.GetTotalMemory(false);
  
          Console.WriteLine(((afterAlloc - beforeAlloc) / System.Int32.MaxValue).ToString());
       }
  }
  </code></pre>
  
  <p>But the <a href="http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory(v=vs.110).aspx" rel="nofollow">documentation</a> specifies that <code>GC.GetTotalMemory()</code> method only retrieves the number of bytes currently <strong>thought</strong> to be allocated, so is there no easy way of finding out without a more sophisticated memory profiler?</p>