While playing around with SOS a little today I took two looks at the output of the command:
!dumpheap -stat
First I ran.
static void Main(string[] args){} //breakpoint here
Next I added a Console.Writeline.
static void Main(string[] args){Console.WriteLine("Hello!");} //breakpoint here
Output of the dumpheap of the first bit of code:
!dumpheap -stat PDB symbol for mscorwks.dll not loaded total 2074 objects Statistics: MT Count TotalSize Class Name 790fdd5c 1 12 System.Security.Permissions.SecurityPermission 790fd5b4 1 24 System.OperatingSystem 790fc79c 1 24 System.Reflection.Assembly 790fb668 1 28 System.SharedStatics 790fce28 1 32 Microsoft.Win32.Win32Native+OSVERSIONINFO 79124544 1 36 System.Int64[] 790fd444 1 40 Microsoft.Win32.Win32Native+OSVERSIONINFOEX 790fbcfc 1 40 System.AppDomainSetup 790fdc3c 1 44 System.Security.FrameSecurityDescriptor 790fd4ec 2 48 System.Version 790f9c18 4 48 System.Object 790fc308 3 60 System.RuntimeType 790fa800 3 60 System.Text.StringBuilder 790fca24 1 64 System.IO.UnmanagedMemoryStream 790fd824 2 72 System.Security.PermissionSet 790fac70 1 72 System.ExecutionEngineException 790fabcc 1 72 System.StackOverflowException 790fab28 1 72 System.OutOfMemoryException 00153d48 6 84 Free 790fb8c8 1 100 System.AppDomain 790fad14 2 144 System.Threading.ThreadAbortException 79124670 6 356 System.Char[] 79124228 4 8288 System.Object[] 790fa3e0 2028 130364 System.String Total 2074 objects
The output for the second bit of code:
!dumpheap -stat PDB symbol for mscorwks.dll not loaded total 4451 objects Statistics: MT Count TotalSize Class Name 79110e94 1 12 System.Resources.FastResourceComparer 79107f40 1 12 System.RuntimeTypeHandle 79102f48 1 12 System.__Filters 79102ef8 1 12 System.Reflection.Missing 79101ca8 1 12 System.RuntimeType+TypeCacheQueue 790fdd5c 1 12 System.Security.Permissions.SecurityPermission 79178564 1 16 System.IO.MdaHelper 79126bd8 1 16 System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Reflection.CustomAttributeData, mscorlib]] 79126710 1 16 System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Reflection.CustomAttributeTypedArgument, mscorlib]] 79111010 1 16 System.Resources.ResourceReader+TypeLimitingDeserializationBinder 7910fe28 1 16 System.Globalization.GlobalizationAssembly 7910646c 1 16 System.Reflection.Cache.InternalCache 79168874 1 20 System.Diagnostics.StackTrace 79126824 1 20 System.Reflection.CustomAttributeTypedArgument[] 7910fbdc 1 20 System.Environment+ResourceHelper 7910031c 1 20 Microsoft.Win32.SafeHandles.SafeFileMappingHandle 791002c0 1 20 Microsoft.Win32.SafeHandles.SafeViewOfFileHandle 790ff26c 1 20 System.Text.InternalEncoderBestFitFallback 790fdf38 1 20 Microsoft.Win32.SafeHandles.SafeFileHandle 7910f690 1 24 System.Collections.Stack 791009f0 1 24 System.IO.TextWriter+SyncTextWriter 790ff2c4 1 24 System.Text.InternalDecoderBestFitFallback 790fd5b4 1 24 System.OperatingSystem 790fc79c 1 24 System.Reflection.Assembly 790f8648 1 24 System.Runtime.CompilerServices.RuntimeHelpers+ExecuteWithLockHelper 79125330 1 28 System.Reflection.Cache.InternalCacheItem[] 791008f0 1 28 System.Text.EncoderNLS 790fe4b0 1 28 System.IO.Stream+NullStream 790fde94 1 28 Microsoft.Win32.Win32Native+InputRecord 790fb668 1 28 System.SharedStatics 791064d8 1 32 System.Reflection.Cache.ClearCacheHandler 79100760 2 32 System.Text.DecoderReplacementFallback 79100700 2 32 System.Text.EncoderReplacementFallback 790fce28 1 32 Microsoft.Win32.Win32Native+OSVERSIONINFO 79124544 1 36 System.Int64[] 790fe280 1 36 System.IO.__ConsoleStream 790f992c 1 36 System.Resources.RuntimeResourceSet 79110f4c 1 40 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter 790fd444 1 40 Microsoft.Win32.Win32Native+OSVERSIONINFOEX 790fbcfc 1 40 System.AppDomainSetup 790fdc3c 1 44 System.Security.FrameSecurityDescriptor 79193fa4 1 48 System.RuntimeMethodHandle[] 7910fc38 2 48 System.Environment+ResourceHelper+GetResourceStringUserData 79107714 1 48 System.Reflection.Module 790ffbe4 4 48 System.UInt16 791687fc 1 52 System.Diagnostics.StackFrameHelper 79126534 1 52 System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Resources.ResourceLocator, mscorlib]] 790fb238 1 52 System.Threading.Thread 790f96e8 1 52 System.Resources.ResourceManager 7912545c 1 56 System.LogLevel[] 791005d4 2 56 System.Text.UTF8Encoding 791003f8 1 56 System.IO.StreamWriter 790ffb28 3 60 System.Globalization.CultureTableItem 79110c2c 2 64 System.Text.UTF8Encoding+UTF8Decoder 7910feec 2 64 System.Globalization.CompareInfo 79126398 1 72 System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[System.Resources.ResourceLocator, mscorlib]][] 790ffa34 1 72 System.Globalization.CultureTable 790fd824 2 72 System.Security.PermissionSet 790fac70 1 72 System.ExecutionEngineException 790fabcc 1 72 System.StackOverflowException 790fab28 1 72 System.OutOfMemoryException 790ff138 1 76 System.Text.SBCSCodePageEncoding 79110b54 2 80 System.IO.BinaryReader 7910fcec 1 80 System.Resources.ResourceReader 79102fac 3 96 System.Reflection.MemberFilter 79102e10 3 96 System.Runtime.CompilerServices.RuntimeHelpers+CleanupCode 791079cc 1 100 System.Reflection.MetadataArgs+SkipAddresses 790fb8c8 1 100 System.AppDomain 00153d48 7 100 Free 79125594 1 108 System.SwitchStructure[] 79102cec 4 128 System.Runtime.CompilerServices.RuntimeHelpers+TryCode 790ffe6c 1 128 System.Globalization.NumberFormatInfo 790f9c18 11 132 System.Object 790fad14 2 144 System.Threading.ThreadAbortException 79109a4c 4 240 System.Reflection.AssemblyName 790ff6dc 5 240 System.Globalization.CultureTableRecord 790fed1c 20 240 System.Int32 790fd4ec 10 240 System.Version 790fca24 4 256 System.IO.UnmanagedMemoryStream 791689a4 9 288 System.Diagnostics.StackFrame 791251f8 1 288 System.Reflection.CustomAttributeRecord[] 790fa800 20 400 System.Text.StringBuilder 7912747c 23 552 System.Collections.Generic.List`1[[System.Reflection.FieldInfo, mscorlib]] 79127200 23 552 System.Collections.Generic.List`1[[System.Reflection.RuntimeFieldInfo, mscorlib]] 791270bc 23 552 System.Collections.Generic.List`1[[System.Reflection.PropertyInfo, mscorlib]] 790ff4c4 8 576 System.Globalization.CultureInfo 79124958 25 600 System.Collections.Generic.List`1[[System.Reflection.RuntimeConstructorInfo, mscorlib]] 791240f0 12 608 System.Int32[] 79127404 23 644 System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1[[System.Reflection.RuntimeFieldInfo, mscorlib]] 79127044 23 644 System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1[[System.Reflection.RuntimePropertyInfo, mscorlib]] 79124b5c 24 672 System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1[[System.Reflection.RuntimeConstructorInfo, mscorlib]] 791273a8 46 736 System.Reflection.CerArrayList`1[[System.Reflection.RuntimeFieldInfo, mscorlib]] 79126fe8 46 736 System.Reflection.CerArrayList`1[[System.Reflection.RuntimePropertyInfo, mscorlib]] 79124418 14 780 System.Byte[] 79125c30 28 784 System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1[[System.Reflection.RuntimeMethodInfo, mscorlib]] 79124b00 49 784 System.Reflection.CerArrayList`1[[System.Reflection.RuntimeConstructorInfo, mscorlib]] 791100e4 23 828 System.Reflection.CustomAttributeData 7910b170 26 1144 System.Reflection.RtFieldInfo 7910aaf4 25 1200 System.Reflection.RuntimeConstructorInfo 790fc308 60 1200 System.RuntimeType 791036b0 51 1224 System.Collections.ArrayList 79125a94 90 1440 System.Reflection.CerArrayList`1[[System.Reflection.RuntimeMethodInfo, mscorlib]] 791256cc 62 1488 System.Collections.Generic.List`1[[System.Reflection.RuntimeMethodInfo, mscorlib]] 791275c8 23 1620 System.Reflection.CustomAttributeCtorParameter[] 79124670 20 1756 System.Char[] 79126e40 74 1776 System.Collections.Generic.List`1[[System.Reflection.RuntimePropertyInfo, mscorlib]] 790fea70 34 1904 System.Collections.Hashtable 79124d0c 156 2120 System.RuntimeTypeHandle[] 7910ae58 39 2340 System.Reflection.ParameterInfo 7910b778 51 2856 System.Reflection.RuntimePropertyInfo 79101be8 40 3200 System.RuntimeType+RuntimeTypeCache 79101e90 62 3472 System.Reflection.RuntimeMethodInfo 791242ec 34 4896 System.Collections.Hashtable+bucket[] 7910adcc 107 5136 System.Signature 79126d08 23 5512 System.Reflection.CustomAttributeNamedParameter[] 79124228 649 25308 System.Object[] 790fa3e0 2251 144908 System.String Total 4451 objects
So 2000+ objects to do... "nothing" and then 2400 additional classes to output one string to the Console.
Seems a lot, but it illustrates how much management it takes to have a managed environment.