Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Test case: https://github.com/wotzisname/open-xml-sdk-xamarin (I used 529ce7014f50dd77f6d342af0450df5f40546700)
Change the architecture to ARMv7 and run on device. It will usually crash either at startup or when tapping the only button (might have to try a couple of times, once in a while it does actually work as well. Adding a couple of CWLs and rebuilding might make it easier to hit too).
The problem seems to be in the OpenXmlSdk.iOS.dll assembly, it's a 6.0MB assembly which turns into 357MB of native assembly and a 100MB object file. A quick look at the symbols seems to indicate many generic instantiations of different enum types:
> nm OpenXmlSdk.iOS.dll.armv7.o | grep EnumValue.*cctor|wc
531 1593 59002
All those 531 types seems to be a generic type instantiated with different enum types.
> nm OpenXmlSdk.iOS.dll.armv7.o |grep System_Collections_Generic_KeyValuePair|wc
19467 58401 3700340
This one has classes as well, but I couldn't find one struct instantiation which wasn't an enum.
Zoltan, can you have a look?
We generate all generic instances we can find the source assembly if they are not instantiated with reference types, thats why there are so many instances here.
Generic value sharing is a fallback to avoid situations where no instance is found, we currently only avoid generating instances of the generic collection classes i.e. List/Dictionary because of it, we don't avoid generating instances of user classes.
Currently, there is no solution here other than modifying the source code.
Cycle6 will include support for sharing these instances.
With current master, the object file size is down to 71mb, but the compiled aot image still contains about 70k methods, so a lot of things are still not shared.
With mono master, the object file is down to 43mb, and the number of generic methods is down to 160.