Bug 25737 - Unloading image System.dll
Summary: Unloading image System.dll
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 5.1
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-01-06 05:30 UTC by martinalderson
Modified: 2016-03-21 10:03 UTC (History)
7 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED ANSWERED

Description martinalderson 2015-01-06 05:30:36 UTC
It seems recently when making specifically https (not http) calls via restsharp (may well be other http clients) we get a lot of logcat stuff along the lines of:

09-23 13:46:24.647 D/Mono    (13657): Unloading image System.dll [0x7d8d4a78].
09-23 13:46:24.647 D/Mono    (13657): Image addref System[0x7d435348] -> System.dll[0x7a75dce8]: 2167
09-23 13:46:24.647 D/Mono    (13657): Unloading image System.dll [0x7d8d4a78].
09-23 13:46:24.647 D/Mono    (13657): Image addref System[0x7d8e33e0] -> System.dll[0x7a75dce8]: 2168
09-23 13:46:24.647 D/Mono    (13657): Unloading image System.dll [0x7d8d4a78].
09-23 13:46:24.657 D/Mono    (13657): Image addref System[0x7d435348] -> System.dll[0x7a75dce8]: 2169
09-23 13:46:24.677 D/Mono    (13657): Unloading image System.dll [0x7d8d4a78].
09-23 13:46:24.677 D/Mono    (13657): Image addref System[0x7d8e33e0] -> System.dll[0x7a75dce8]: 2170
09-23 13:46:24.677 D/Mono    (13657): Unloading image System.dll [0x7d8d4a78].
09-23 13:46:24.687 D/Mono    (13657): Image addref System[0x7d8e33e0] -> System.dll[0x7a75dce8]: 2171
09-23 13:46:24.687 D/Mono    (13657): Unloading image System.dll [0x7d8d4a78].
09-23 13:46:24.687 D/Mono    (13657): Image addref System[0x7d6e7d20] -> System.dll[0x7a75dce8]: 2172
09-23 13:46:24.687 D/Mono    (13657): Unloading image System.dll [0x7d8d4a78].
09-23 13:46:24.687 D/Mono    (13657): Image addref System[0x7d8e33e0] -> System.dll[0x7a75dce8]: 2173
09-23 13:46:24.707 D/Mono    (13657): Unloading image System.Core.dll [0x7e9c30c8].
09-23 13:46:24.707 D/Mono    (13657): Image addref System.Core[0x7e9c4a98] -> System.Core.dll[0x7a615f00]: 622
09-23 13:46:24.707 D/Mono    (13657): Unloading image System.Core.dll [0x7e9c30c8].
09-23 13:46:24.707 D/Mono    (13657): Image addref System.Core[0x7d85f388] -> System.Core.dll[0x7a615f00]: 623

You can see on the forums other people are reporting this issue. It seems that other people are getting this too. https://forums.xamarin.com/discussion/10272/unloading-image-system-dll-log-spam

It causes really bad performance issues for us (we are doing autosuggest so send a lot of small https requests frequently).
Comment 1 Artur Shamsutdinov 2015-02-15 22:34:34 UTC
Same issue when using ModernHttlpClient with https.
Comment 2 Jonathan Pryor 2015-02-17 13:24:44 UTC
Those messages are not problematic; they are advisory in nature, as Xamarin.Android 4.10 and later set the default mono log level for Debug builds to MONO_LOG_LEVEL=info:

http://developer.xamarin.com/releases/android/xamarin.android_4/xamarin.android_4.10/

That said, I'm not sure why these assemblies are constantly loaded and unloaded...
Comment 3 Anonymous 2015-10-01 11:05:32 UTC
First, thank you Jonathan for your response concerning why these messages are now popping up and how we can ignore them. That being said I have a request.

"I'm not sure why these assemblies are constantly loaded and unloaded..."

Maybe I'm out of line here but doesn't the constant loading and unloading seem like a red flag to anyone? These messages are advisory in nature. They are advising us that something, somewhere, is doing a whole lot of repetitive work.

I would like a definitive answer on why this happens before I hide this output. If there is a good reason for all the loading/unloading, I will sleep fine after hiding this output forever. If however there's an issue somewhere it would be nice to know about it rather than sweeping it under the rug by hiding the output.
Comment 4 Pavel Sich 2016-01-07 17:32:01 UTC
Jonathan, can we please get some response?

This is hitting us quite bad as well. It looks like our HTTPS requests are 2x slower than HTTP, and this is very concerning.

Please can we get anyone to have a look at it and give us a definitive answer how we can ensure the System.Core stays loaded and does not need constant switch?

-Pavel
Comment 5 Jonathan Pryor 2016-01-07 20:52:01 UTC
> It looks like our HTTPS requests are 2x slower than HTTP, and this is very concerning.

Isn't HTTPS supposed to be slower than HTTP?

That aside, I'm not sure why unloading images would result in a 2x performance decrease.

That also aside, do you have a repro for the Unloading image messages?

I (mistakenly?) remember that the default app template would produce these message. However, I do not see those messages wrt System.dll/etc. in Xamarin.Android 6.0:

> monodroid: Using override path: /data/user/0/scratch.bxc37422/files/.__override__
> monodroid: Using override path: /storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__
> monodroid: Trying to load sgen from: /data/user/0/scratch.bxc37422/files/.__override__/libmonosgen-2.0.so
> monodroid: Trying to load sgen from: /storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__/libmonosgen-2.0.so
> monodroid: Trying to load sgen from: /data/app/scratch.bxc37422-1/lib/arm/libmonosgen-2.0.so
> monodroid: Trying to load sgen from: /data/user/0/scratch.bxc37422/files/.__override__/links/libmonosgen-2.0.so
> Mono    : Image addref mscorlib[0xa8671620] -> mscorlib.dll[0xacc37200]: 1
> Mono    : AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/app/scratch.bxc37422-1/lib/arm/libaot-mscorlib.dll.so" not found
> Mono    : AOT module '/Users/builder/data/lanes/2098/3efa14c4/source/monodroid/builds/install/mono-armv7/lib/mono/aot-cache/arm/mscorlib.dll.so' not found: dlopen failed: library "/data/app/scratch.bxc37422-1/lib/ar
> nd
> Mono    : Unloading image data-0xaecc0000 [0xacc37700].
> Mono    : Assembly mscorlib[0xa8671620] added to domain RootDomain, ref_count=1
> Mono    : Assembly Loader probing location: '/storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__/Scratch.Bxc37422.dll'.
> Mono    : Image addref Scratch.Bxc37422[0xa8671740] -> /storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__/Scratch.Bxc37422.dll[0xacc38100]: 2
> Mono    : Assembly Scratch.Bxc37422[0xa8671740] added to domain RootDomain, ref_count=1
> Mono    : AOT module '/storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__/Scratch.Bxc37422.dll.so' not found: dlopen failed: library "/data/app/scratch.bxc37422-1/lib/arm/libaot-Scratch.Bxc37422.dl
> 
> Mono    : AOT module '/Users/builder/data/lanes/2098/3efa14c4/source/monodroid/builds/install/mono-armv7/lib/mono/aot-cache/arm/Scratch.Bxc37422.dll.so' not found: dlopen failed: library "/data/app/scratch.bxc37422-
> .dll.so" not found
> Mono    : Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__/Scratch.Bxc37422.dll'.
> Mono    : Config attempting to parse: '/storage/emulated/0/Android/data/scratch.bxc37422
> ...

The "Unloading image" messages?

> Mono    : Unloading image data-0xaecc0000 [0xacc37700].
> Mono    : Unloading image data-0x9b100000 [0xb4d77900].
> Mono    : Unloading image data-0xa8d00000 [0xb3fd7a00].

These correspond to unloading debug symbol files (which have no corresponding "loaded" message.

Are you able to provide a repro that shows that System.dll is being unloaded?

Does that repro use AppDomains? Unloading an AppDomain will unload all assemblies contained within it, which would include System.dll/etc.
Comment 6 Pavel Sich 2016-01-08 16:04:22 UTC
Hello, thank you for answer.

I was mentioning these kind of logs:

Info: At top of (REAL) ApiSender.Send
[Mono] The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
[Mono] Unloading image System.Core.dll [0x8fbd8f00].
[Mono] Image addref System.Core[0x8ff3b580] -> System.Core.dll[0x9840e300]: 230
[Mono] The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
[Mono] Unloading image System.Core.dll [0x8fbd8f00].
[Mono] Image addref System.Core[0x8ff3b580] -> System.Core.dll[0x9840e300]: 231

My setup is:
Xamarin.Android
Version: 6.0.0.34 (Business Edition)
Android SDK: /Users/pavelsich/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.3.4
SDK Platform Tools Version: 23
SDK Build Tools Version: 23

Java SDK: /usr
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Xamarin Studio
Version 5.10.1 (build 6)
Installation UUID: 14418d28-71d7-49b2-89fc-a21792287b50
Runtime:
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102
Comment 7 Jonathan Pryor 2016-01-08 16:22:29 UTC
> I was mentioning these kind of logs:
> 
> Info: At top of (REAL) ApiSender.Send
> [Mono] The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
> [Mono] Unloading image System.Core.dll [0x8fbd8f00].
> [Mono] Image addref System.Core[0x8ff3b580] -> System.Core.dll[0x9840e300]: 230
> [Mono] The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
> [Mono] Unloading image System.Core.dll [0x8fbd8f00].
> [Mono] Image addref System.Core[0x8ff3b580] -> System.Core.dll[0x9840e300]: 231

Right, but *where* are you seeing those messages? Is this in `adb logcat` or somewhere else? Is this with Xamarin.Android 6.0 or some previous version?

As mentioned in Comment #5, I *thought* I saw those messages in `adb logcat` in previous versions, but I no longer see similar messages in Xamarin.Android 6.0.