Considering how much functionality is in the .NET Framework and how .NET PE files’ metadata is highly compressed, one would expect most .NET applications to be very small.

You can empirically observe this by trying to create a simple “Hello World” in C#: the resulting executable is just 3.5KB (or even smaller with versions prior to 2.0). The size does not increase by much as you continue adding code and reasonably sized (in functionality) .NET applications are just a couple of hundred KB or even less.

Just the other day I checked to see how big the core part of my P2P BitTorrent app was – 160KB. Hm, this doesn’t look right; I keep this library lean in general, it should be smaller.

So I fired up ILDASM (IL DisAsseMbler) and checked the overall statistics (View->Statistics). Here’s the important part:

 File size            : 163840
 PE header size       : 4096 (496 used)   ( 2.50%)
 PE additional info   : 1219              ( 0.74%)
 Num.of PE sections   : 3
 CLR header size      : 72                ( 0.04%)
 CLR meta-data size   : 81268             (49.60%)
 CLR additional info  : 0                 ( 0.00%)
 CLR method headers   : 11081             ( 6.76%)
 Managed code         : 54814             (33.46%)
 Data                 : 8192              ( 5.00%)
 Unaccounted          : 3098              ( 1.89%)

Well, well, well… 50% of the image is actually metadata! Despite heavy metadata “compression” (this is a custom kind of compression) in the .NET Framework, metadata occupies half of the total space, while code takes only 34%. Interesting…

I guess if I obfuscate the image using an IL round-tripping obfuscator that I could get quite a smaller image.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
0 Comments