Bug 15455 - Error executing task LinkAssemblies: Out of memory
Summary: Error executing task LinkAssemblies: Out of memory
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.8.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Radek Doulik
Depends on:
Reported: 2013-10-17 08:47 UTC by Allie Miller
Modified: 2016-10-27 13:59 UTC (History)
10 users (show)

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

Logs from Case #49080 (112.12 KB, application/zip)
2013-10-22 08:37 UTC, Allie Miller
Android Tools Log files from Case #49080 (100.56 KB, application/zip)
2013-10-22 08:38 UTC, Allie Miller
test project for this issue (964.74 KB, application/zip)
2013-10-31 05:34 UTC, Dave
$HOME/Library/Logs/XamarinStudio-5.0/Ide.log (214.16 KB, text/plain)
2015-12-07 08:11 UTC, Thomas Van den Bossche

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 for Bug 15455 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Allie Miller 2013-10-17 08:47:02 UTC
Since upgrading to mono 3.x.x series, when running Xamarin Studio for ~30 minutes the following error appears:

"Error executing task LinkAssemblies: Out of memory"

If Xamarin Studio is then closed and the memory is cleared using something like FreeMemory app, Xamarin Studio can be restarted without the error appearing for another 30 minutes. This did not occur in the Mono 2.1.0 series.

Additionally, when compiling the software the amount of available memory on the system continues to go down until there is nothing left.

This occurs for both android and iOS projects. Specifically, a compile of an android + PCL projects. When they are launched in to the emulator can take 800mbs out of the system each time, which is only released when Xamarin Studio is closed.

Full versioning information below:
Xamarin Studio
Version 4.0.13 (build 38)
Installation UUID: 04a3b306-9452-49ee-9fb7-29f9ea3fc18b
Mono 3.2.3 ((no/8d3b4b7)
GTK+ 2.24.20 theme: Raleigh
GTK# (
Package version: 302030000

Apple Developer Tools
Xcode 5.0 (3332.22)
Build 5A1412

Xamarin.Mac: Not Installed

Version: (Business Edition)
Hash: 57edee2
Build date: 2013-04-10 18:05:51-0400

Version: 4.8.3 (Business Edition)
Android SDK: /Users/XXXX/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
4.0 (API level 14)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Build Information
Release ID: 400130038
Git revision: 07afec667f7be5d0ee511eb7115bbac6377fbae8
Build date: 2013-09-24 08:53:29+0000
Xamarin addins: 61140345a5b109633a94409edcbc7a4c19a425c6

Operating System
Mac OS X 10.8.5
Darwin ACCESS-902DHJY-iMac.local 12.5.0 Darwin Kernel Version 12.5.0
Sun Sep 29 13:33:47 PDT 2013
root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
Comment 1 Mikayla Hutchinson [MSFT] 2013-10-17 13:46:46 UTC
Sounds like the Android MSBuild targets are leaking and our MSBuild host is running out of memory.
Comment 2 Jonathan Pryor 2013-10-17 15:57:10 UTC
A repro and/or a stack trace would be nice. As-is, I don't know where to even start.

Please provide $HOME/Library/Logs/XamarinStudio-4.0/Ide.log, which should contain the stack trace.
Comment 3 Allie Miller 2013-10-22 08:37:15 UTC
Created attachment 5201 [details]
Logs from Case #49080
Comment 4 Allie Miller 2013-10-22 08:38:11 UTC
Created attachment 5202 [details]
Android Tools Log files from Case #49080
Comment 6 Jonathan Pryor 2013-10-23 22:25:45 UTC
Thank you for the logs. This is the relevant error, from Ide.2013-10-16__10-17-37.log:

> System.Exception: MSBuild operation failed
> Server stack trace: 
>   at MonoDevelop.Projects.Formats.MSBuild.BuildEngine.RunSTA (System.Threading.ThreadStart ts) [0x00000] in <filename unknown>:0 
>   at MonoDevelop.Projects.Formats.MSBuild.ProjectBuilder.RunTarget (System.String target, MonoDevelop.Projects.Formats.MSBuild.ProjectConfigurationInfo[] configurations, ILogWriter logWriter, MSBuildVerbosity verbosity) [0x00000] in <filename unknown>:0 
>   at (wrapper managed-to-native) System.Runtime.Remoting.RemotingServices:InternalExecute (System.Reflection.MethodBase,object,object[],object[]&)
>   at System.Runtime.Remoting.RemotingServices.InternalExecuteMessage (System.MarshalByRefObject target, IMethodCallMessage reqMsg) [0x00000] in <filename unknown>:0 
> Exception rethrown at [0]: 
>  ---> System.OutOfMemoryException: Out of memory
>   at (wrapper managed-to-native) object:__icall_wrapper_mono_gc_alloc_vector (intptr,intptr,intptr)
>   at (wrapper alloc) object:AllocVector (intptr,intptr)
>   at System.Collections.ArrayList.EnsureCapacity (Int32 count) [0x00000] in <filename unknown>:0 
>   at System.Collections.ArrayList.Add (System.Object value) [0x00000] in <filename unknown>:0 
>   at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0 
>   at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in <filename unknown>:0 
>   at Mono.Linker.Steps.MarkStep.Process () [0x00000] in <filename unknown>:0 
>   at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0 
>   at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0 
>   at MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0 
>   at MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options, Mono.Linker.LinkContext& context) [0x00000] in <filename unknown>:0 
>   at Xamarin.Android.Tasks.LinkAssemblies.Execute () [0x00000] in <filename unknown>:0 
>   at Microsoft.Build.BuildEngine.TaskEngine.Execute () [0x00000] in <filename unknown>:0 
>   at Microsoft.Build.BuildEngine.BuildTask.Execute () [0x00000] in <filename unknown>:0 
>   --- End of inner exception stack trace ---
>   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x001e9] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:248 

How large is your project? Specifically, `du -sh $ProjectDir/bin/Release` (the combined size of all assemblies referenced by your app).
Comment 7 Dave 2013-10-30 11:14:07 UTC

Running that script returns 3.1m as the combined size.

Can i add that this does not seem to be a Android specific problem.
Comment 8 Dave 2013-10-31 05:34:46 UTC
Created attachment 5288 [details]
test project for this issue

I have included a test project, which includes a class called NetworkClient.  When testing to find the cause of the issue, by removing components from our project, as soon as I removed this class the issue went away.  I have removed any real logic from the class, but the issue still occurs as it is.  The thing with this class is that it is use an external dll, RestSharp, so I don't know if this is the a starting point to the problem.

Unfortunately the test project is quite a bit smaller than my real project, but the memory grabbing can be anywhere from 10-100mbs on this project(as opposed 300-500mb).  I just don't have time to add in more code to make the project larger.

Also please note, that this is "compile" problem not a deployment problem and can be replicated without deploy to a device or the emulator.
Comment 9 Dave 2013-11-01 04:12:11 UTC
this error can also occur when the memory leak happens.

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Error executing task GetAdditionalResourcesFromAssemblies: error XA0009: Error while loading assembly: /Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/platforms/android-14/Mono.Android.dll (AMF_Android)
Comment 10 Dave 2013-11-01 05:24:30 UTC
And this one

/Library/Frameworks/Mono.framework/Versions/3.2.3/lib/mono/4.0/Microsoft.CSharp.Targets: Error: Error executing task Csc: Thread creation failed. (AMF_Android)
Comment 11 Allie Miller 2013-11-15 11:21:21 UTC
This issue is still occurring after updating to the latest version of the software. The full versioning information is below:

=== Xamarin Studio ===

Version 4.2.1 (build 1)
Installation UUID: 785601a2-6a98-4c72-9a92-0db698610484
Mono 3.2.4 ((no/294f999)
GTK+ 2.24.20 theme: Raleigh
GTK# (
Package version: 302040000

=== Apple Developer Tools ===

Xcode 5.0.2 (3335.32)
Build 5A3005

=== Xamarin.Mac ===

Xamarin.Mac: Not Installed

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 23a0827
Build date: 2013-11-11 16:04:00-0500

=== Xamarin.Android ===

Version: 4.10.1 (Business Edition)
Android SDK: /Volumes/Data/DevelopmentData/android-sdk-mac_x86
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
3.2 (API level 13)
4.0 (API level 14)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Build Information ===

Release ID: 402010001
Git revision: 844a84fe0aa0cb5f986d4e3c4807a51487d07845
Build date: 2013-11-13 22:12:16+0000
Xamarin addins: 97e44e4863da6c479427794457637e75b3d22600

=== Operating System ===

Mac OS X 10.9.0
Darwin XXXXX Darwin Kernel Version 13.0.0
Thu Sep 19 22:22:27 PDT 2013
root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
Comment 12 Dave 2014-03-21 04:46:46 UTC
Hi Guys,

This issue does now seem to have gone away and I am able to use XS all day without issue.

I'm not sure if this is because of a fix in XS or XA or the fact that I moved the networking code to a seperate project.

Comment 13 Paul Hart 2014-04-18 13:50:12 UTC
I am having this problem too.
Comment 16 John Miller [MSFT] 2015-02-06 14:06:44 UTC
Customer hitting similar issue.

Version 5.7 (build 661)
XA Version:
Mono 3.12.0
GTK+ 2.24.23
java version "1.7.0_71"
Mac OS X 10.10.2
Comment 18 Jonathan Pryor 2015-02-06 16:07:12 UTC
@John: Can we get a copy of their project?

It's an OutOfMemoryException while linking. How big is this project?
Comment 19 Jonathan Pryor 2015-02-06 16:07:54 UTC
@Radek: Any chance you could "memory optimize" the linker so that it requires less memory? (Probably requires the project requested in Comment #18...)
Comment 20 Radek Doulik 2015-02-27 10:42:02 UTC
I am unable to reproduce it with the original test case.

@John: would it be possible to get the project or simplified test case from the customer?
Comment 21 Thomas Van den Bossche 2015-12-07 08:11:31 UTC
Created attachment 14142 [details]
Comment 22 Thomas Van den Bossche 2015-12-07 08:12:28 UTC
I'm still having the same issues with Xamarin Studio 5.10 and Xamarin Android

I've provided the log from Xamarin Studio.
Comment 23 Sam 2016-09-06 11:24:20 UTC
This is still happening in the latest version. It happens after building my (huge) project a couple of times. Will attach a log next time it happens.

=== Xamarin Studio Business ===

Version 6.0.2 (build 73)
Installation UUID: 76317d7b-5495-4e06-84ed-25d9915361ca
	Mono 4.4.2 (mono-4.4.0-branch-c7sr1/f72fe45) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404020011

=== Xamarin.Profiler ===

Version: 0.34.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.Mac ===

Version: (Xamarin Business)

=== Xamarin.iOS ===

Version: (Xamarin Business)
Hash: f37444a
Branch: cycle7-sr1
Build date: 2016-07-28 12:17:02-0400

=== Xamarin.Android ===

Version: (Xamarin Business)
Android SDK: /Users/sam/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		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: 25.1.7
SDK Platform Tools Version: 24.0.2
SDK Build Tools Version: 24.0.2

Java SDK: /usr
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

Android Designer EPL code available here:

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 600020073
Git revision: a6f7a24a9723a2d4f5d33c176615b0d44703ab5b
Build date: 2016-07-26 13:36:15-04
Xamarin addins: f5acb37866a0141bc5ddbe95118f18dae4014568
Build lane: monodevelop-lion-cycle7-sr1

=== Operating System ===

Mac OS X 10.11.6
Darwin mbpsam.local 15.6.0 Darwin Kernel Version 15.6.0
    Mon Aug 29 20:21:34 PDT 2016
    root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

JSON Copy 1.1