Getting OutOfMemoryException in Xamarin
Solution 1
I would increase your build heap size.
Right click your Android Project > Properties > Android Options > Advanced > Java Max Heap Size.
Solution 2
The selected answer lead me in the right direction, but for Visual Studio 2017, the screen looks like:
Solution 3
If you want to increase Heap size of your application (not the build process) you can set this in your AndroidManifest.xml:
<application android:largeHeap="true"></application>
Solution 4
For visual studio 2015 right click Project --> Properties --> Android Options --> Advanced and heap size there.
Solution 5
As of Xamarin studio version 6.3 and visual studio 7.0.1 the option to increase heap size can be found here
Right click on the android project then choose options and choose, Build/Android Build, then Advanced tab and set 1G (or something) in Java heap size
Related videos on Youtube
Srinivas Ch
Working As A senior software developer at Jaaji Technologies Pvt ltd. Having 3.7 Years of Experience in C#,WCF,ASP.Net MVC 4.5,Xamarin Android.
Updated on July 05, 2022Comments
-
Srinivas Ch almost 2 years
java.lang.OutOfMemoryError. Consider increasing the value of $(JavaMaximumHeapSize). Java ran out of memory while executing 'java.exe'
I am getting out of memory exception in my visualstudio Xamarin Project Please help me how can i resolve this issue.
-
tequila slammer about 8 yearsI would like to recommend not only to set LargeHeap to true. Instead you should try to figure out what is causing that OOM and fix that. Otherwise you might have bought you some time until it will hit you again.
-
-
Srinivas Ch about 8 yearsYes Your right. But where can i up my app size in visual studio xamarin.
-
SushiHangover about 8 years@SrinivasCh In your manifest add the
android:largeHeap="true"
tag and then watch yourlogcat
forGrow heap (frag case)
to see when ART is trying to allocate more memory -
Srinivas Ch about 8 yearsWorks well Thanks for reply @lain Smith
-
Iain Smith about 8 years@SushiHangover Ah ok, I have had that error before and just upped the heap here, but you are right if you want your have to use a large heap then edit the manifes
-
Iain Smith about 8 years@Srinivas-Ch no worries
-
SushiHangover about 8 years@IainSmith, ahhh, need more coffee, I thought he was a app ART memory alloc failure, not a build error... cheers
-
LionelGoulet over 7 yearsMake that: left-click <project>.Droid --> Double-click 'Properties' --> Click 'Android Options' on the left --> Click 'Advanced' tab --> "Java Max Heap Size"
-
King Chan almost 6 yearsfor me other than 1G I had to also set build with x64 and JDK to 8 instead of latest or 9 :(