Monday, September 15, 2008

How Many Types are loaded for Hello World

Fairy princess

Consider the following super simple C# code

namespace SmartDeviceProject1
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Hello");
}
}
}

Can you guess how many managed Type gets loaded to run this? I was doing some profiling the .NET Compact Framework loader (for entirely unrelated reason) and was surprised by the list that got dumped. 87 types**, never could've guessed that...



  1. System.Object
  2. System.ValueType
  3. System.Type
  4. System.Reflection.MemberInfo
  5. System.Delegate
  6. System.MarshalByRefObject
  7. System.SystemException
  8. System.Exception
  9. System.Attribute
  10. System.Collections.Hashtable
  11. System.Enum
  12. System.Reflection.BindingFlags
  13. System.MulticastDelegate
  14. System.Reflection.MemberFilter
  15. System.Reflection.Binder
  16. System.Reflection.TypeAttributes
  17. System.DateTime
  18. System.Collections.IDictionary
  19. System.UnhandledExceptionEventHandler
  20. System.AppDomainManager
  21. System.Version
  22. System.Decimal
  23. System.Runtime.InteropServices.ComInterfaceType
  24. System.Collections.ICollection
  25. System.Collections.IEqualityComparer
  26. System.AppDomainManagerInitializationOptions
  27. System.ArithmeticException
  28. System.ArgumentException
  29. System.MissingMemberException
  30. System.MemberAccessException
  31. System.AppDomainSetup
  32. System.Reflection.AssemblyName
  33. System.Globalization.CultureInfo
  34. System.Reflection.Assembly
  35. System.Configuration.Assemblies.AssemblyHashAlgorithm
  36. System.Configuration.Assemblies.AssemblyVersionCompatibility
  37. System.Reflection.AssemblyNameFlags
  38. System.Globalization.CultureTableRecord
  39. System.Globalization.CompareInfo
  40. System.Globalization.TextInfo
  41. System.Globalization.NumberFormatInfo
  42. System.Globalization.DateTimeFormatInfo
  43. System.Globalization.Calendar
  44. System.Globalization.BaseInfoTable
  45. System.Globalization.CultureTable
  46. System.Globalization.CultureTableData
  47. System.Globalization.NumberStyles
  48. System.Globalization.DateTimeStyles
  49. System.Globalization.DateTimeFormatFlags
  50. System.Globalization.TokenHashValue
  51. System.Globalization.CultureTableHeader
  52. System.Globalization.CultureNameOffsetItem
  53. System.Globalization.RegionNameOffsetItem
  54. System.Globalization.IDOffsetItem
  55. System.TokenType
  56. System.Char
  57. System.IO.TextReader
  58. System.IO.TextWriter
  59. System.IFormatProvider
  60. System.Console
  61. System.RuntimeTypeHandle
  62. System.NotSupportedException
  63. System.Globalization.EndianessHeader
  64. System.Reflection.Missing
  65. System.RuntimeType
  66. System.Threading.StackCrawlMark
  67. System.Globalization.CultureTableItem
  68. System.Int32
  69. System.Security.CodeAccessSecurityEngine
  70. System.AppDomain
  71. System.LocalDataStoreMgr
  72. System.Threading.ExecutionContext
  73. System.LocalDataStore
  74. System.Collections.ArrayList
  75. System.Threading.SynchronizationContext
  76. System.Runtime.Remoting.Messaging.LogicalCallContext
  77. System.Runtime.Remoting.Messaging.IllogicalCallContext
  78. System.Threading.Thread
  79. System.Collections.Generic.Dictionary`2
  80. System.Runtime.Remoting.Messaging.CallContextRemotingData
  81. System.RuApplication starting
  82. System.Collections.Generic.IEqualityComparer`1
  83. Runtime.Remoting.Messaging.CallContextSecurityData
  84. System.Array
  85. System.RuntimeFieldHandle
  86. System.Globalization.CultureTableRecord[]
  87. System.Text.StringBuilder

**This is for the compact framework CLR. Your mileage will vary if you run the same on the desktop CLR.

No comments: