Akash Amin
Akash Amin

Reputation: 2761

Using XAML compiler does not decrease application size

Working on application performance and found this link https://developer.xamarin.com/guides/xamarin-forms/user-interface/xaml-basics/xamlc/. It says the final application size will decrease after using,

[XamlCompilation (XamlCompilationOptions.Compile)]

at class level, but my application size increased after using this. It went from 30308kB to 30379kB. I know it's just some kB's but still it increased where as I thought it must decrease. Anyone knows about this?

Upvotes: 0

Views: 187

Answers (1)

SushiHangover
SushiHangover

Reputation: 74144

How many and how large are your .xaml files to start with?

Without XamlCompilation the .xaml is embedded into your assembly and at runtime, extracted and "parsed" into an object tree.

With XamlCompilation the .xaml is generated into code and thus the IL for the resulting code is included within your assembly like any other code would be.

So, the question goes back to if you only have one or two xaml files, then the generated code and thus generated IL just might be larger, but if you have dozens of templates, styles, pages, etc... then you can save a few bytes. If think about how small the xaml text files are to start with, you are not going to save huge amounts of final app size as those xaml text embedded resources are now IL instructions.

The key features, for me, are #1) the compile-time checking(!), and closely behind is #2 the decrease of instantiation time of a page, and #3 (last for me) is the saving of a few bytes of app size...

Upvotes: 1

Related Questions