Getting OutOfMemoryException in Xamarin

37,646

Solution 1

I would increase your build heap size.

Right click your Android Project > Properties > Android Options > Advanced > Java Max Heap Size.

enter image description here

Solution 2

The selected answer lead me in the right direction, but for Visual Studio 2017, the screen looks like:

VS 2017 Updated Screens

VS 2017 Updated Screens

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

enter image description here

Share:
37,646

Related videos on Youtube

Srinivas Ch
Author by

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, 2022

Comments

  • Srinivas Ch
    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
      tequila slammer about 8 years
      I 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
    Srinivas Ch about 8 years
    Yes Your right. But where can i up my app size in visual studio xamarin.
  • SushiHangover
    SushiHangover about 8 years
    @SrinivasCh In your manifest add the android:largeHeap="true"tag and then watch your logcat for Grow heap (frag case) to see when ART is trying to allocate more memory
  • Srinivas Ch
    Srinivas Ch about 8 years
    Works well Thanks for reply @lain Smith
  • Iain 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
    Iain Smith about 8 years
    @Srinivas-Ch no worries
  • SushiHangover
    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
    LionelGoulet over 7 years
    Make that: left-click <project>.Droid --> Double-click 'Properties' --> Click 'Android Options' on the left --> Click 'Advanced' tab --> "Java Max Heap Size"
  • King Chan
    King Chan almost 6 years
    for me other than 1G I had to also set build with x64 and JDK to 8 instead of latest or 9 :(